init
Example
const init = require('@mimik/init');
init(config, dbValidate, { postOps: [suscribe] }).then(result => config = result);
object
⏏
module.exports(app, rootDir, config, validates, cluster, options) ⇒ Init process for a micro-service.
Kind: Exported function
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 genetrate information for `/metrics`
}
The return
object has the following strucuture:
{
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
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 . |