Server Hook Configuration File

A server hook configuration file defines the timing when your server code is launched. It is to be deployed together with the server code.

There are two types of timing (hooks) you can specify in a server hook configuration file (For the detailed explanation, see Functionality of Server Code).

  • Trigger-based Hook: This will allow your server code to be executed when the designated trigger occurred on the server-side.
  • Schedule-based Hook: This will allow your server code to be executed on the designated time.

All settings are to be written in one JSON file. See the following example of a server hook configuration file. In this example, five hooks (user creation, creation and deletion of an application scope bucket, every 0 min and every day on 2:30 UTC) are defined.

{
  "kiicloud://users": [
    {
      "when": "USER_CREATED",
      "what": "EXECUTE_SERVER_CODE",
      "endpoint": "userCreated"
    }
  ],
  "kiicloud://buckets/highScore": [
    {
      "when": "DATA_OBJECT_CREATED",
      "what": "EXECUTE_SERVER_CODE",
      "endpoint": "highScoreCreated"
    },
    {
      "when": "DATA_OBJECT_DELETED",
      "what": "EXECUTE_SERVER_CODE",
      "endpoint": "highScoreDeleted"
    }
  ],
  "kiicloud://scheduler": {
    "HourlyCheck": {
      "what": "EXECUTE_SERVER_CODE",
      "cron": "0 * * * *",
      "endpoint": "checkData",
      "parameters": {
        "executionType": "hourly",
        "target": "user"
      }
    },
    "DailyCheck": {
      "what": "EXECUTE_SERVER_CODE",
      "cron": "30 2 * * *",
      "endpoint": "checkData",
      "parameters": {
        "executionType": "daily",
        "target": "all"
      }
    }
  }
}

An endpoint specified in a server hook configuration file will be automatically launched when the conditions are met. It can be also launched manually via the client SDK.