node package manager


An express configuration helper, to make a simple configuration even simpler.


An express configuration helper, to make a simple configuration even simpler.

Expressly 2.x now uses Express 4.x.

Use Expressly 1.x to use with Express 3.x.

$ npm install expressly --save

expressly is a function that takes in an express app and a configuration object. expressly will give you a common setup for express app. The idea is for it to be production quality, so please, if you have any suggestions for additional middleware to be provided please make it known (or contribute). I also plan on making it more extensible in the future. If you have any ideas for how to implement that, send me a PR and I'll take it into consideration.

Here is how you would use it:

var express   = require('express')
  , expressly = require('expressly')
  , http      = require('http')
  , app       = express()
  , server    = http.createServer(app)
  , port      = '3000'
// Below are the defaults, so it's the same as calling 'expressly(app);' 
expressly(app, {
  publicDirectory: './public', // this can be a relative or absolute path. 
  cacheAge: 0,
  csrf: false,
  session: {
    store: false,
    secret: 'change this secret',
    proxy: false,
    resave: true,
    saveUninitialized: true,
    cookie: {
      path: '/',
      httpOnly: true,
      maxAge: null
server.listen(port, function () {
  console.log('Express server started on port:', port);

Here is a list of the middleware used:

// The next two are only used if the session configuration is set 
app.use(require('express-session')({/* session config */}));
// The next two are only use if the csrf and session configurations are set 
app.use(function (req, res, next) {
  res.cookie('XSRF-TOKEN', req.csrfToken());
app.use(express.static(dir, {maxAge: cacheAge}));

expressly will return an ErrorObject if there was a known error. Otherwise, submit an issue and we'll get it taken care of.

I typically don't use express views because I've used front-end frameworks for dynamic pages, but it's something I would consider using. For now, you can just do this:

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

This project uses gulp for task automation.

$ npm install -g gulp

Here are the three tasks available to use:

  • gulp hint: runs all pertinent code against jshint. The rules are the ones defined in .jshintrc

  • gulp test: runs all tests with mocha for passing and instanbul for code coverage. It generates html files showing the code coverage.

  • gulp docs: builds out all of the documentation using docco. Note that you need to have docco installed (npm install -g docco). I at one time at docco part of the dev dependencies, but now I don't. I may be open to putting it back, but I just wanted to keep the package as small as possible.

You can also run npm test, and it does basically does the same thing as gulp test, but an error will be thrown because it does some more istanbul stuff to send data to the coverage server. When this project runs through travis, it also sends coverage data to

When forking and doing pull requests, work off of the develop branch. I won't be super strict on this, but it's what I would prefer. That way we can keep master clean.