README
express-common
Take the big boilerplate app.js
generated by express
CLI and reduce it to
this:
var common = require('express-common')
var express = require('express')
var app = express()
common.preRoutes(app)
// Your routes
var routes = require('./routes/index')
var users = require('./routes/users')
app.use('/', routes)
app.use('/users', users)
common.postRoutes(app)
module.exports = app
Getting started
- Run
express my_project_name
(make sure you have express-generator globally installed withnpm install -g express-generator@4
) - Replace
app.js
with the Javascript above.
Options
common.preRoutes(app, {
viewPath: 'views', // in your root directory
viewEngine: 'jade',
staticPath: 'public', // in your root directory
logName: 'app'
})
common.postRoutes(app, {
exposeStackTraces: false
})
Notes
- Bunyan replaces Morgan for logging. Use
"scripts": {"start": "node ./bin/www | ./node_modules/bunyan/bin/bunyan"}
for pretty-printing