During development the Server Code script can be quickly tested inside editor.
When you are done writing the script, the script has a REST API URL which can be invoked from your app. In other words, a script is also a way to create a custom REST API.
- Console – used to print data for information or debugging purposes.
- Collection – provides integration with the Appery.io database.
- Database user – provides integration with the Users collection from Appery.io database.
- Push Notifications – used to send Push Notifications messages.
- Request – holds request (input) information for the script.
- Response – used as a response (answer) for the request.
- ScriptCall – used to call another script.
- XMLHttpRequest – used to send HTTP requests to web server and retrieve any type of data directly back into the script.
- In Memory Data (IMD) – allows to store any data in fast memory for 20 minutes. It works like a very fast cache.
In addition to writing scripts, you can also create libraries. A library can include logic that can be included and re-used in other scripts.
Some examples using Server Code:
- Run any custom logic/calculations.
- Get data from the Appery.io database, process/format the data that makes sense for the app.
- Send a targeted Push Notification message.
- Check the database and if some condition is met (for example: low inventory), send a Push Notification message and email to the appropriate people.
- Invoke an external REST API, process/format the response and return a result that make sense for the app.
- Invoke two external REST APIs, combine the data in a format that makes sense for the app.
- Write a script that registers and signs in a user from the app.
As mentioned at the beginning, a script is invoked via its REST API. You can also schedule a script to run periodically. It’s called a Job. For example, you can schedule a script to run once a day.
A script can be made secure which means a user login will be required before a script can be invoked. A user is created inside the Appery.io database Users collection.
With build-in versioning, a script version can be saved and restored at any point.
Server Code snippets and plug-ins provide sample code that can be quickly inserted into any script.