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.
openNG/app.js

67 lines
1.2 KiB
JavaScript

var app, bodyParser, cookieParser, express, favicon, logger, path, routes, users;
10 years ago
express = require('express');
10 years ago
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();
10 years ago
app.set('views', path.join(__dirname, 'views'));
10 years ago
app.set('view engine', 'jade');
app.use(favicon());
10 years ago
app.use(logger('dev'));
10 years ago
app.use(bodyParser.json());
10 years ago
app.use(bodyParser.urlencoded());
10 years ago
app.use(cookieParser());
app.use(express["static"](path.join(__dirname, 'public')));
10 years ago
app.use('/', routes);
10 years ago
app.use('/users', users);
app.use(function(req, res, next) {
var err;
err = new Error("Not Found");
err.status = 404;
return next(err);
10 years ago
});
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
10 years ago
});
});
10 years ago
}
app.use(function(err, req, res, next) {
res.status(err.status || 500);
return res.render("error", {
message: err.message,
error: {}
});
10 years ago
});
module.exports = app;