Skip to content

Instantly share code, notes, and snippets.

@L8D
Created September 23, 2014 02:35
Show Gist options
  • Select an option

  • Save L8D/1c5e04e4c5c414c14aa1 to your computer and use it in GitHub Desktop.

Select an option

Save L8D/1c5e04e4c5c414c14aa1 to your computer and use it in GitHub Desktop.
var parser = require('body-parser')
, config = require('./config')
, express = require('express')
, morgan = require('morgan')
, _ = require('lodash')
, path = require('path')
;
var app = module.exports = express();
app
.use(morgan(config.env === 'development' ? 'combine' : 'dev'))
.use(express.static(path.resolve(__dirname + '/public')))
.use(express.static(path.resolve(__dirname + '/dist')))
.use(parser.json())
;
app.use(function(req, res) {
res.status(404);
if (req.accepts('html')) {
res.sendfile(path.resolve(__dirname + '/public/404.html'));
} else {
res.send('Not found');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment