Objective
As known, SOAJS offers a wide range of solutions for APIs.
Assuming you are using a different technology, nodeJS based, now using the 'soajs.nodejs' middleware, you can benefit from all SOAJS advantages.
This space will show you:
- How does it work on init
- How does it work on request
How does it work on init
Using the following environment variables:
SOAJS_REGISTRY_API
SOAJS_ENV
the middleware is going to invoke the controller and get the registry. Using the service configuration provided, the mw will auto reload the registry every "serviceConfig.awareness.autoRelaodRegistry"
Once the registry is loaded, the middleware is now ready to act on request.
How does it work on request
Once a request is reached, the SOAJS controller will be passing through the request headers a 'soajsinjectobj' which will be mapped within the middleware to the following standard object:
{ tenant : { id : '', code : '' }, key : { config : {}, iKey : '', eKey : '' }, application : { product : '', package : '', appId : '', acl : {}, acl_all_env : {} }, package :{ acl :{}, acl_all_env : {} }, device : '', geo : {}, urac : {}, awareness : { host : '', port : '', getHost : 'function' } }
Hence you can now use the following set of functions appended to req.soajs.reg:
{ getDatabases: returns database object if dbName provided, if not, return all core and tenant meta databases getServiceConfig: returns service configuration object getDeployer: returns deployer object getCustom: return custom object getResources: returns resource object if resourceName provided, if not returns all resources getServices: returns service object if serviceName provided, if not, returns all services getDaemons: returns daemon object if daemonName provided, if not, returns all daemons reload: reload registry }
Add Comment