Message:

Subscribe rss
Blog categories
All | Backendless features
Feature 115: Creating Server-Side Business Logic for User Service API with Console
May 3, 2015 by markpiller
Spread the love

In my previous post I introduced the feature of server-side API event handlers – a mechanism for injecting custom business logic into Backendless. In this post I am going to review the process of creating an event handler for User Service APIs using Backendless console. The User Service APIs include: user registration, login, logout, user update, password recovery and retrieval of user schema (a list of user properties and their types). You can build an event handler (or two event handlers – “before” and “after”) for each of these operations.

To simplify the process of developing event handlers, we developed a code generator which is included into Backendless Console. The code generator can create all the required code for event handler, minus the actual business logic which is all that’s left for you to add. For example, suppose a business logic must be triggered every time a user registers with your app . To create an event handler for that API:

  1. In the Backendless Console, click the Business Logic icon.
  2. Select Users in the list of Event Handlers (the reason you need to select “Users” is because we are adding an event handler for one of the User Service APIs).
  3. Click the Add Event Handler button.
  4. Select Register from the Event drop-down. Your screen should look as shown below:
    adding user service event handler - Feature 115: Creating Server-Side Business Logic for User Service API with Console

As you can see, the user interface lets you pick an event for which you’re going to create an event handler. You can also select the “timing” of the handler by selecting the “Before” or “After” option. Finally, you can choose the event handler to be executed either synchronously or asynchronously. The latter means the API processing chain will not wait for the handler to complete its execution.

When you click Save, Backendless Console automatically generates the code for the event handler:
event handler generated code - Feature 115: Creating Server-Side Business Logic for User Service API with Console

Similarly to Timers, you can download the code to add your own business logic. In the future posts I will be reviewing the process of debugging and deploying the event handlers to Backendless.

Enjoy!

Share this post
Tweet about this on TwitterShare on FacebookGoogle+