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/serviceName
is 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
auth
field, 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 retrievalin the field
stringClassName
- the class name of the received objects, in this case the classclass_string@develop-and-test
will be passed to thegetList
method of the data repositoryoptions.dataRepo.getList(options.stringClassName, {})