Appey.io Server Code is a powerful tool that allows you to write custom server-side business logic for your app. These are the benefits you get when you use Server Code:
- Write and implement any business logic for an app. For example, you can write a script that checks inventory (Database), then sends a push notification, and then sends an e-mail using the SendGrid API
- Quickly test the script during development
- A Server Code script is instantly exposed via a REST API. This means you can quickly build a custom API
And there’s more…
- Keep sensitive data such as API keys and tokens on the server. This means this data won’t be exposed on the client
- A Server Code script has easy-to-use API access to other Appery.io Backend Services such as Database and Push
- A script can be saved as a library and used in other scripts
- Create a script version with built-in versioning
- Script changes can be made without updating the client (app)
- Schedule a script (job) to run periodically
- Use In Memory Data for fast cache
Let’s look at a quick example creating a Server Code script to search Wikipedia for a particular key word.
This is how the script looks:
var query = request.get("query");
var XHRResponse = XHR2.send("GET", "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + query);
Line 1: The script reads the query parameter.
Line 3: The script connects to a third-party API (Wikipedia) for searching.
Line 5: The response from the Wikipedia API is used as the response for the script.
The script is very simple, but shows you how fast and simple it is to add custom business logic to your app.
This is how the script looks inside the Server Code script editor:
Then click Save and Run button from Run tab:
It’s simple and fast to create a custom script. In our example, we created a script that searches Wikipedia. The script is also instantly exposed via a REST API:
Appery.io Server Code is the fastest way to build custom business logic for your app. Please check out our Build in 5 Minutes video series to learn more.