Service registration in application configuration

To connect services in the application, they must be configured in the global settings of the rest module in the application’s deploy.json file. Example:

{
  "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 service registrations in the file deploy.json - modules.rest.globals.di. Next, the name of the service which will be available at https://domain.com/rest/serviceNameis specified , where serviceName is the name of the service, specified in di, for example simple or string-list in the example above .

In the module attribute the path to the js-file with the service handler is specified with the path relatively to the framework root. The handler can be either in the application or in any module or framework, including standard 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 is specified.

And for the string-list service the following settings are specified:

  • 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, {})