pr-express-server
v0.1.1
Published
ExpressJS based server with useful middlewares
Downloads
8
Maintainers
Readme
pr-express-server
ExpressJS based server with useful middlewares
Philosophy
Simple and ready-to-use express-server pre-loaded with commonly used middleware provided as a starting point for development
Installation
$ npm install pr-express-server
APIs
The module exposes a simple create-function and returns an ExpressJS app with pre-loaded middleware. These middleware can be configured via options passed to the function. The app also has updated methods to start/listen and stop/close the server.
var server = require("pr-express-server");
// create server
var app = server(options);
// setup the business-login as would with an express-app
app.set(); // properties
app.use(); // handlers
// start
app.listen(callback);
// stop
app.close(callback);
Following is the list of middleware that are pre-loaded and configurable via options - you may refer to the documentation of the respective modules for options:
| Type | Option-key | Documentation | | :------- | :--------- | :------------ | | Req/Res Logger | winstonHttpLogger | express-winston | | Overload Protection | toobusy | toobusy-js | | Request ID | requestID | key: name; generator: function| | Request Logger | requestLogger | key: name; logger: logger-object | | HTTP Compression | compression | compression | | Req Body-parser | bodyParser | express-body-parser | | Security Headers | helmet | helmet | | Cookie Session | redisCookieSession | express-redis-session | | Websockets | expressWs | express-ws | | Sockets Monitoring| wsMonitor | ws-monitor | | Listening Port | port | http-port |
Refer to default options for reference at: defaults.js
Usage
Refer to test server.js implementation for usage details.
Test
$ npm install # inside pr-express-server
$ npm test