express-commondeprecated

Avoid boilerplate express app.js

Usage no npm install needed!

<script type="module">
  import expressCommon from 'https://cdn.skypack.dev/express-common';
</script>

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

  1. Run express my_project_name (make sure you have express-generator globally installed with npm install -g express-generator@4)
  2. 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

  1. Bunyan replaces Morgan for logging. Use "scripts": {"start": "node ./bin/www | ./node_modules/bunyan/bin/bunyan"} for pretty-printing