Quickly Add Custom Business Logic to Your App with Server Code

Screen Shot 2015-07-01 at 2.45.21 PM

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
  • JavaScript is the language used to write the script
  • Server Code is based on the popular V8 JavaScript engine. This means you can use any APIs supported by V8
  • 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
  • Import any third-party JavaScript libraries to use the script
  • 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);

response.success(XHRResponse, "application/json");

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:

Screen Shot 2015-07-02 at 4.24.59 PM

Server Code script editor

Testing the script is fast and simple. First, enter the parameter the script requires (the script will search for ‘JavaScript’):

Screen Shot 2015-07-02 at 4.27.14 PM

Testing – script parameters

Then click Save and Run button from Run tab:

Screen Shot 2015-07-02 at 4.28.23 PM

Testing – running the script

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:

Script REST API

Script 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.