'use strict';
var express = require('express'),
kraken = require('kraken-js');
var app = express();
app.use(kraken());
app.listen(8000);
All kraken-js configuration settings are optional.
basedir
(String, optional) - specify the working directory for kraken-js to use.onconfig
(Function, optional) - provides an asynchronous hook for loading additional configuration. Signature:function (config, cb) { /* ... */ }
protocols
(Object, optional) - protocol implementations for use when processing configuration. For more information on protocols see shortstop.uncaughtException
(Function, optional) - Handler foruncaughtException
errors. See the endgame module for defaults.
Using environment suffixes, configuration files are applied and overridden according to the current environment as set
by NODE_ENV
. The application looks for a ./config
directory relative to the basedir and recursively scans for all JSON
files contained therein. JSON files without a suffix or with an environment suffix that matches the current env are
processed an loaded. Additionally, JSON configuration files may contain comments.
Valid NODE_ENV
values are undefined
or dev[elopment]
, test[ing]
, stag[e|ing]
, prod[uction]
. Simply
add the suffix for a file to have it read only in that environment, e.g. config/app-development.json
.
Powered by shortstop, configuration files can contain values that are resolved at runtime. Default shortstop protocol handlers include:
path:{path}
- resolves the provided value against the applicationbasedir
.file:{path}
- loads the contents of the specified file.base64:{data}
- converts the base64-encoded value to a buffer.
Middleware is completely configuration-based. meddleware is used internally to read, resolve, and register middleware with your express application.
TODO
TODO
kraken-js adds support for the following events to your express app instance:
start
- the application has started and is ready to accept requests.shutdown
- the application is shutting down, no longer accepting requests.stop
- the http server is no longer connected or the shutdown timeout has expired.error
-
$ npm test
$ npm run-script cover && open coverage/lcov-report/index.html
```