$ npm install @knetik/micro-express
Then add the COREADAPTORS config to your
"CORE_ADAPTORS": [ '@knetik/micro-express' ]
ExpressSets up an http web server built with Express and Run when calling
Core.serve(app_root_path). Routes are stored in
app/routesand should be wrapped in a function with a single
Multi tenancy is handled on a per request basis using an express middleware.
Core.connect(app_id, bearer_token)is called internally returning an app instance scoped to the client and attaching it to the
requestobject. Access to the App instance is demonstrated in the example route.
Multi tenant resolution is keys on the requesting appid. The
app_idis resolved from the first sub domain segment of the requesting domain or from the configured
APP_ID_KEYrequest header. Which defaults to
Service Auto LoadSet the
AUTO_LOAD_SERVICE_ROUTESenv var to true. This will load the modules inside
app/servicesas routes and apply a default route to each service. Config options are available for a auto loaded service. Refer to the DOCS for more info on how to configure auto loaded service routes
/routesfor a list of the auto loaded routes. If the
AUTO_LOAD_SERVICE_ROUTESvar is not set, this route will not be available.
SwaggerSwagger json and swagger ui are supported through jsdoc parsing and an express static route.
- use swagger yaml syntax in a doc block - https://github.com/knetikmedia/micro-core/blob/master/app/routes/example.js#L3-L28
- view the auto generated swagger.json file - /swagger.json
- render the swagger ui - /swagger-ui