2015-07-20 09:41:58 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var fs = require("fs");
|
|
|
|
var path = require("path");
|
|
|
|
var morgan = require("morgan");
|
|
|
|
var express = require("express");
|
|
|
|
var winston = require("winston");
|
|
|
|
var config = require("./config.js");
|
2015-07-29 10:46:30 +00:00
|
|
|
var favicon = require("serve-favicon");
|
|
|
|
var exphbs = require("express-handlebars");
|
2015-07-20 09:41:58 +00:00
|
|
|
var env = process.env.NODE_ENV || "development";
|
|
|
|
var pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "../package.json")));
|
|
|
|
|
|
|
|
module.exports = function (app) {
|
2015-07-29 10:46:30 +00:00
|
|
|
app.use(express.static(path.join(__dirname, '../public')));
|
|
|
|
app.use(favicon(path.join(__dirname, '../public/images/favicon.ico')));
|
2015-07-20 09:41:58 +00:00
|
|
|
|
|
|
|
// Use winston on production
|
|
|
|
var log;
|
|
|
|
if (env !== 'development') {
|
|
|
|
log = {
|
|
|
|
stream: {
|
|
|
|
write: function (message, encoding) {
|
|
|
|
winston.info(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
log = 'dev';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (env !== 'test') app.use(morgan(log));
|
|
|
|
|
|
|
|
var hbs = exphbs({
|
|
|
|
defaultLayout: 'main',
|
|
|
|
extname: '.hbs'
|
|
|
|
});
|
|
|
|
|
|
|
|
app.engine('.hbs', hbs);
|
|
|
|
app.set('view engine', '.hbs');
|
2015-07-29 10:46:30 +00:00
|
|
|
};
|