@mimik/init

5.3.0 • Public • Published

init

Example

const init = require('@mimik/init');

init(config, dbValidate, { postOps: [suscribe] }).then(result => config = result);

module.exports(app, rootDir, config, validates, cluster, options) ⇒ object

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. The base path is defined by taking the url property of the first item of the servers array in the api defintion 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.

Readme

Keywords

Package Sidebar

Install

npm i @mimik/init

Weekly Downloads

11

Version

5.3.0

License

MIT

Unpacked Size

19.8 kB

Total Files

12

Last publish

Collaborators

  • sasan.raisdana
  • miburger
  • hofachiang
  • mimik-npm-editor
  • mimikopensource