Feature

Cloud Code

At A Glance

There are three types of Cloud Code: API Services, API Event Handlers, and Timers. API Services is a perfect example of how Backendless supports serverless computing. The behavior of any built-in Backendless API can be modified with API Event Handlers – your Cloud Code executed in the API processing chain, which lets you tailor the built-in APIs to work in a way that best suits your app. You can also use Cloud Code to develop timers – logic that is executed by Backendless according to the schedule you define.

Cloud Code

Your Code, Our Servers

We give you the ability to run Java, JavaScript (Node.js), and Codeless logic on our servers. Backendless is 100% serverless, which means you can focus on your application’s functionality and leave the infrastructure to us. The Backendless infrastructure is highly scalable and your Cloud Code is automatically provisioned so your growth is never limited by server capacity. Security is automatically integrated with your app – you can easily configure rules for access to your Cloud Code to apply to your app users and security roles.

Cloud Code Generator

Getting started with Backendless Cloud Code is easy – simply use the code generator to create code declarations for API Event handlers and Timers. Likewise, Backendless generates a logic placeholder for Codeless, giving you a starting point for crafting your Codeless logic. If you prefer to write your own code, JavaScript/Node.js Cloud Code can be edited directly in Backendless Console. When you’re ready, you can promote your code from draft to production with a click of a button.

API Services

API Services is an example of serverless in Backendless – freeing you from worrying about deployment, procurement, scaling and invocation handling so you can focus on the logic of your microservices. API services can be developed with Java, JavaScript/Node.js, and Codeless. With API Services, you can:

  • Use any Backendless API to work with the Backendless Database, send out push notifications and emails, perform user management functions, etc.
  • Connect to resources outside of Backendless, such as third-party services and APIs.
  • Process invocations directly from Backendless Console.
  • Generate client-side SDKs for Android, iOS and JavaScript. The generated SDKs include all the logic for handling service invocation from your application.
  • Track service usage and invocations in Backendless Analytics so you can see exactly how the service is consumed by your customers.

API Event Handlers

Every API invocation in Backendless comes with two server-side events for which you can add your own Cloud Code. We refer to that code as “before” and “after” event handlers. The “before” event is fired before the default logic of the API implementation is executed and the “after” event is triggered right after the default API implementation logic. For example, a “before” event handler can modify or validate the data sent by your client application. Similarly, an “after” handler can modify the return value so the client application that made the API request receives the modified value. These are just two examples of the many actions event handlers can perform. You can use the Backendless SDK in your Cloud Code to take advantage of everything Backendless has to offer.

Cloud Code Timers

Backendless Timers are Cloud Code logic that executes according to a schedule. You can create a custom schedule to launch the timer’s logic at a predefined time and repeat at a specified frequency, such as daily, weekly or monthly (with many custom scheduling variations). A timer can use Backendless APIs to work with the data/users/files in your Backendless storage, execute any kind of business logic, and communicate with external services/resources.

Manage Custom Code In Production

Once your Cloud Code is deployed into the cloud, Backendless Console provides a way to control the execution of your code. Any API service, API event handler or timer can be easily enabled, disabled or completely removed from the production environment.

Backendless API In Your Server Code

Quite often, your Cloud Code needs to access application data, work with user information, access files, send emails or push notifications, etc. All these tasks can be done using the same Backendless API you use to build your client-side app. You do not need to learn anything new – all the capabilities in our SDK are available for use in custom server-side code. Your Java Cloud Code can use the Backendless SDK for Java/Android and the JavaScript/Node.js Cloud Code would use the SDK for JS.

Local Cloud Code Debugging

Developing custom code that runs in the cloud presents a challenge – you need to deploy the code into the cloud to see it working. That is not the case with Backendless. We provide a powerful set of tools for you to debug your Cloud Code locally, on your own computer. What makes it even more powerful is that while the code you debug runs locally, it is accessible through Backendless Cloud. This makes it possible to run your Cloud Code in debug mode the same way it would execute in production, only on your local computer rather than Backendless servers.

Real-Time Logging

Your Cloud Code can use the Backendless logging API for storing informational, debugging and diagnostics information in your log files. Log files are available via Backendless Console. Additionally, Backendless Console provides a logging monitor that displays your Cloud Code log messages in real-time.