An express configuration helper, to make a simple configuration even simpler.
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
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 = expressserver = httpcreateServerappport = '3000';// Below are the defaults, so it's the same as calling 'expressly(app);'expresslyapppublicDirectory: './public' // this can be a relative or absolute path.cacheAge: 0csrf: falsesession:store: falsesecret: 'change this secret'proxy: falseresave: truesaveUninitialized: truecookie:path: '/'httpOnly: truemaxAge: null;serverlistenportconsole.log'Express server started on port:' port;;
Here is a list of the middleware used:
appuserequire'compression';appuserequire'body-parser';appuserequire'method-override';// The next two are only used if the session configuration is setappuserequire'cookie-parser';appuserequire'express-session'/* session config */;// The next two are only use if the csrf and session configurations are setappuserequire'csurf';appuserescookie'XSRF-TOKEN' reqcsrfToken;next;;appuseexpressstaticdir 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:
appset'views' pathjoin__dirname 'views';appset'view engine' 'jade';expresslyapp;serverlistenport;
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
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 coveralls.io.
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