@sigfox/koa-maintenance
v1.0.0
Published
Koa middleware to manage maintenance.
Downloads
1
Readme
koa-maintenance
Koa middleware to manage maintenance mode.
When use it?
You can use this module if you need to manage the maintenance mode of your Koa app.
Features
Switch on or off at startup the maintenance mode of your Koa app, if on it will send a 503 status to all incoming requests, if off it will go through the maintenance middleware without modifications of the incoming request. The HTTP status code and the body's response can be customised via the options
parameter.
Install
npm install @sigfox/koa-maintenance
Usage
isOn
(Boolean
) (default: "false"
): The flag to indicate if the maintenance is on or off, default is off.options
(Object
) (default
: "{ status: 503, message: "We are currently down for maintenance." }"): The options to customise status code and body's response.
const Koa = require('koa');
const maintenance = require('@sigfox/koa-maintenance');
const app = new Koa();
app.use(
maintenance(process.env.MAINTENANCE === 'true', {
status: 503,
message: 'Something amazing is coming, bear with us'
})
);
const server = app.listen();
Test
npm test
Licence
This project is licensed under the MIT License - see the LICENSE file for details.