@modern-mean/server-express-module
TypeScript icon, indicating that this package has built-in type declarations

0.3.9 • Public • Published

Join the chat at https://gitter.im/modern-mean npm version dependencies Status devDependencies Status Build Status Coverage Status 

#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);

Package Sidebar

Install

npm i @modern-mean/server-express-module

Weekly Downloads

2

Version

0.3.9

License

ISC

Last publish

Collaborators

  • modern-mean