@modern-mean/server-express-module
v0.3.9
Published
Modern-Mean module for express
Downloads
56
Maintainers
Readme
#server-express-module Modern Mean module for express server
#Installation
$ npm install --save @modern-mean/server-express-module
#Exports
- ExpressModule class
#ExpressModule Methods
- listen - Instructs the Express app to start listening
- destroy - Gracefully destroys the class, including the express App, http Server, and https server. Not available in Production Environment
- getExpressApp - Returns the express app. Useful for passing into additional modules.
- getHttpServer - Returns the Node http server
- getHttpsServer - Returns the Node https server.
#Configuration You can choose to set environment variables to override the configuration or pass them into the ExpressModule constructor
##Environment Variables You can use environment variables on the commandline to override the configuration. Environment variables must be strings so you cannot use object, arrays, boolean, etc. Ex:
EXPRESSMODULE_HTTP_PORT=8081
Or set them in your main applications gulpfile.babel.js. https://github.com/modern-mean/generator-modern-mean/blob/master/generators/app/templates/server/gulpfile.babel.js
You can set any environment variables in these two files. https://github.com/modern-mean/server-express-module/blob/master/src/config.js https://github.com/modern-mean/server-express-module/blob/master/src/logger.js
##Constructor You can also override the configuration in the ExpressModule Constructor. This is useful for configurations that cannot exist as strings. The constructor configuration will override the default configuration AND environment variable configuration. For example if you wanted to customize the Helmet middleware:
https://github.com/helmetjs/helmet
If you wanted to configure the frameguard middleware then you would override the helmet configuration
let expressConfig = {
config: {
helmet: {
config: {
frameguard: {
action: 'deny'
}
}
}
}
};
let expressModule = new ExpressModule(expressConfig);