express-configurator

0.0.2 • Public • Published

express-configurator

With Express 4.x, each middleware item has become it's own module. While the reasons for separating them is clear, the standard developer flow is still to include the base set provided by the express team here. Adding many of these to your package.json is a pretty significant amount of bloat to me, and since I tend to use the same modules between projects, I decided to create a module to manage the modules and versions.

Usage

var express = require('express'),
    expressConfigurator = require('express-configurator');
    
var app = express();
    
expressConfigurator.init(app, [
  // Add middleware by name and get the default config
  'errorhandler',
  'method-override',
  
  // Or use an object to provide your own config
  { name: 'morgan', config: 'dev' },
  
  // You can also provide the 'context' param
  // app.use('/static', serveStatic('./static'))
  { name: 'serve-static', config: './static', context: '/static' },
  
  // For more complex configurations, you can use submodules.
  // The example shown here is body parser, which is typically represented as 
  // express.use(bodyParser.json());
  // express.use(bodyParser.urlEncoded({ extended: true });
  {
    name: 'body-parser',
    config:
      {
        submodules: [
          'json', 
          { name: 'urlencoded', config: { extended: true } }
        ]
      }
    }
]);

Todos

  • Defaults aren't actually provided yet, just an empty object for now
  • Some tests around things would be good
  • Check that all the standard modules are being used. Specifically I think cookie-parser is deprecated.

Readme

Keywords

none

Package Sidebar

Install

npm i express-configurator

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • shortstuffsushi