Blog

How to work with Cloud Code (overview)

by on April 24, 2015

This is an introductory post for a very broad feature – injecting custom server-side logic into Backendless. There are a lot of smaller features in Cloud Code (also known as Custom Business Logic), but it’s worth it to start with a general overview. As you have seen in the previous recipe posts, services included in Backendless execute specific and well-defined operations based on the received arguments. For example, the Login API request checks if the user credentials are valid and, if they are, establishes a session.

An API call to search for an object in a data table finds the object and returns it back to the client. There are many scenarios when the built-in functionality either should be augmented to perform some additional logic or completely overridden. This is exactly what Cloud Code does – it is a framework that lets you inject your own code into the Backendless API invocation chain.

Cloud Code relies on the concept of event handlers, where an event is an API invocation request. For example, the Login API request is the Login event. For every event, there are two possible handlers: a “before” and “after” handler. These handlers are where your custom code can be injected. The following diagram demonstrates the API invocation chain:

Your Cloud Code is deployed to the Backendless cloud and thus entirely managed by Backendless. Our service is responsible for making sure that the code is properly deployed and distributed to guarantee high availability and scalability. There are a lot of very cool features to simplify the process of building Cloud Code and my future posts will be reviewing them in great detail.

Enjoy!