This package adds the an express http server to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a Core Adaptor


3.1.1a month ago3 years agoMinified + gzip package size for @knetik/micro-express in KB


Knetik Micro Express

This package adds the an express http server to any micro-core application as a Core Adaptor


$ npm install @knetik/micro-express

Then add the CORE_ADAPTORS config to your config/environments/*.json files

"CORE_ADAPTORS": [ '@knetik/micro-express' ]


Sets up an http web server built with Express and Run when calling Core.serve(app_root_path). Routes are stored in app/routes and should be wrapped in a function with a single Server parameter.

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 request object. Access to the App instance is demonstrated in the example route.

Multi tenant resolution is keys on the requesting app_id. The app_id is resolved from the first sub domain segment of the requesting domain or from the configured APP_ID_KEY request header. Which defaults to x-knetikcloud-appid

Service Auto Load

Set the AUTO_LOAD_SERVICE_ROUTES env var to true. This will load the modules inside app/services as 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

Navigate to /routes for a list of the auto loaded routes. If the AUTO_LOAD_SERVICE_ROUTES var is not set, this route will not be available.


Swagger json and swagger ui are supported through jsdoc parsing and an express static route.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.