@mimik/init
v6.0.4
Published
Init process for micro-service
Readme
init
Example
import init from '@mimik/init';
init(config, dbValidate, { postOps: [subscribe] }).then(result => config = result);init~init(app, rootDir, config, validates, cluster, options) ⇒ object
Init process for a micro-service.
Kind: inner method of init
Returns: object - The updated configuration.
The secOptions has the following structure:
{
preOps: [function], // functions to process before starting the micro-service
postOps: [function], // functions to process after starting the micro-service
exitOps: [function], // functions to process before exiting the micro-service
secOptions: { securityDefinition: function }, // extra security options to validate the API request
extractName: string, // ability to extract data from the req and send it to a logging environment
metrics: object, // to generate information for `/metrics`
}The return object has the following structure:
{
config: The configuration object,
}For the preOps, postOps and exitOps the function are executed with 3 parameters (correlationId, config, server).
The following routes are reserved: /healthcheck and /metrics.
The base path is defined by taking the url property of the first item of the servers array in the api definition file. Only relative url address will be handled (e.g. /mss/v1) and templates in the url are not allowed.
| Param | Type | Description |
| --- | --- | --- |
| app | object | The app implementing the micro-service. |
| rootDir | PATH.<string> | The root directory of the micro-service. |
| config | object | Configuration of the micro-service. |
| validates | array | Array of Promises to validate dependent systems (database, topic). |
| cluster | Promise | Promise to be used for cluster management and registration. |
| options | object | options to start the micro-service. The options can be null. |
