Service registration in application configuration

To enable services in the app, it’s necessary to configure them in the global settings of the rest module in the deploy.json file of the applications. An example is given below.

{
  "modules": {
    "rest": {
      "globals": {
        "di": {
          "simple": {
            "module": "applications/develop-and-test/service/SimpleRest"
          },
          "string-list": {
            "module": "applications/develop-and-test/service/String-list",
            "options": {
              "stringClassName": "class_string@develop-and-test",
              "dataRepo": "ion://dataRepo"
            }
          },
          "crud": {
            "module": "modules/rest/lib/impl/crud",
            "options": {
               "auth": "ion://auth",
               "dataRepo": "ion://securedDataRepo"
            }
          }

The path to the registration service in the file deploy.json is module.reset.globals.di, then specify the name of the service that will be available at https://domain.com/rest/serviceName, where serviceName is the name of the service specified in di, such as in the example above simple or string-list. The attribute `` module`` indicates the path to the js file with the service handler with the path relative to the root of the framework. The handler can be both in the application and in any module or framework, including sample rest module handlers.

The options parameter the specific settings of the service are indicated. For example, for the crud service, the following settings are indicated:

  • in the dataRepo field - data repository with access control used for operations with objects

  • in the authfield - the authentication component used to get the current user account. And for the service string-list:

  • in the dataRepo field - the data repository used for data retrieval

  • in the field stringClassName - the class name of the received objects, in this case the class class_string@develop-and-test will be passed to the getList method of the data repository

    options.dataRepo.getList(options.stringClassName, {})