You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.2 KiB
JavaScript
67 lines
1.2 KiB
JavaScript
var app, bodyParser, cookieParser, express, favicon, logger, path, routes, users;
|
|
|
|
express = require('express');
|
|
|
|
path = require('path');
|
|
|
|
favicon = require('static-favicon');
|
|
|
|
logger = require('morgan');
|
|
|
|
cookieParser = require('cookie-parser');
|
|
|
|
bodyParser = require('body-parser');
|
|
|
|
routes = require('./routes/index');
|
|
|
|
users = require('./routes/users');
|
|
|
|
app = express();
|
|
|
|
app.set('views', path.join(__dirname, 'views'));
|
|
|
|
app.set('view engine', 'jade');
|
|
|
|
app.use(favicon());
|
|
|
|
app.use(logger('dev'));
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(bodyParser.urlencoded());
|
|
|
|
app.use(cookieParser());
|
|
|
|
app.use(express["static"](path.join(__dirname, 'public')));
|
|
|
|
app.use('/', routes);
|
|
|
|
app.use('/users', users);
|
|
|
|
app.use(function(req, res, next) {
|
|
var err;
|
|
err = new Error("Not Found");
|
|
err.status = 404;
|
|
return next(err);
|
|
});
|
|
|
|
if (app.get("env") === "development") {
|
|
app.use(function(err, req, res, next) {
|
|
res.status(err.status || 500);
|
|
return res.render("error", {
|
|
message: err.message,
|
|
error: err
|
|
});
|
|
});
|
|
}
|
|
|
|
app.use(function(err, req, res, next) {
|
|
res.status(err.status || 500);
|
|
return res.render("error", {
|
|
message: err.message,
|
|
error: {}
|
|
});
|
|
});
|
|
|
|
module.exports = app;
|