mns-fe-server
Contributing Guide
This module is a wrapper around the node Express.js server. It takes a single configuration object with the following properties:
Name | Type | Description |
---|
assetsDir | string | Dir to serve static files such as images, CSS files, and JavaScript files |
jsonLogging | function | Function used for logging events, can be used with @mands/mns-fe-foundation/src/components/logger |
logger | boolean | Enable or Disable logging |
routesDir | function | A function that returns the path to the routes directory |
handlebars | object | Handlebars view engine object |
pageNotFoundHandler | function | A mapping to a handler for 404 status events |
errorPageHandler | function | A mapping to a handler for 500 status events |
ExposeRoutes | function | Function which returns a dir with the exposed routes |
Installation and usage
To install mns-fe-server
into your application please run:
npm install --save @mands/mns-fe-server
Include the module and start:
const config = require('./configuration/server')
let server = require('@mands/mns-fe-server')(config)
server.start()
Here's an example configuration object to get you started.
Supplying application specific middlewares
Providing a custom middleware is as simple as adding middlewares
method to config/server.js
. For example:
const middleware = require('<path to middleware>');
const middlewares = server => {
server.use(middleware);
}
module.exports = {
middlewares,
analyticsEnv,
env,
routes,
assetsDir,
jsonLogging,
...
...
}
Documents
Contacts