1.0.0 • Published 4 years ago

@danielyona93/nodejs-server-maintenance v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

nodejs-server-maintenance

Express.js middleware to control server maintenance mode

Installation

yarn add @danielyona93/nodejs-server-maintenance

or

npm install @danielyona93/nodejs-server-maintenance

Usage

Using default options

const maintenance = require('nodejs-server-maintencene');

maintenance(app);

Initializing maintenance mode to true

const maintenance = require('nodejs-server-maintencene');

maintenance(app, true);

Using customized configuration

const maintenance = require('nodejs-server-maintencene');

const options = {
    mode: false,        // default value: false 
    accessKey: 'V1msnCX6',      // optional
    endpoint: '/maintenance',       // default value: /maintenance
    fileRoute: '/views/maintenance.html',       // default value: /views/maintenance.html
    forceMessage: false,        // default value: false
    message: 'Error 503: Server is temporarily unavailable, please try again lager.',       // default value: Error 503: Server is temporarily unavailable, please try again lager.
    useApi: false,      // default value: false
    statusCode: 503     // default value: 503
}

maintenance(app, options);

Setting maintenance mode on

POST request to http://yourserver/[endpoint]?access_key=[accessKey]

Setting maintenance mode off

DELETE request to http://yourserver/[endpoint]?access_key=[accessKey]

Remove access_key query string if no accessKey provided

Variables

NameTypeDescription
modeBooleanSets maintenance mode on/off
accessKeyStringAllows access only using the access key
endpointStringDefines the requestion route after the domain
fileRouteStringSets the route to the HTML file that the server will send when mode is on
forceMessageBooleanForces a simple message instead of using HTML file
messageStringA simple message to display instead of HTML
useApiBooleanIf true, the server will send JSON { statusCode, message }
statusCodeNumberResponse status code
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago