node package manager

fx-middleware

Plugin: fx-middleware

Description

Common express middlewares. Implement the middleware service

Config

specify the argument --middleware [config file path] to config the middleware If the config file is not specified

Interface

morgan

web app server log middleware

config it with 'morgan' field

default:

morgan: {
  path: global.home + '/logs'
  format: 'short', // combined, common, dev, short, tiny, or user defined 
  filePrefix: 'access_'
};

cookieParser

express cookie parser middleware

var cookieParser = require('cookie-parser');
return cookieParser()

urlEncodedParser

var bodyParser = require('body-parser');
return bodyParser().urlencoded({
  extended: true
})

jsonParser

var bodyParser = require('body-parser');
return bodyParser().json()

session

support three types of session:

  • memory
  • mongodb
  • redis

Config the session types with 'sessionStore' config key default: 'memory'

Config the session secret with 'sessionSecret'

Mongodb configuration is defined in mongodb service

Redis configuration is defined in redis service

compression

var compression = require('compression');
return compression()