1 Star 0 Fork 1

leetao/SYServer

forked from code2life/SYServer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.js 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
code2life 提交于 2016-01-23 21:47 . update handlebars
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var hbs = require('hbs');
var routes = require('./routes/index');
var log4js = require('log4js');
var logger = require('./common/config').logger('app');
var app = express();
// view engine setup
app.set('view engine', 'html');
app.engine('html', require('hbs').__express);
//hbs.registerHelper('helper_name', function) {});
hbs.registerPartials(__dirname + '/views');
//app.set('views', path.join(__dirname, 'views'));
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(log4js.connectLogger(logger, {level: 'auto', format:':method :url'}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
routes(app);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
logger.error(err);
res.render('error.hbs', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error.hbs', {
message: err.message,
error: {}
});
});
process.on('uncaughtException', function (err) {
logger.fatal(err);
});
module.exports = app;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LeetaoGoooo/SYServer.git
git@gitee.com:LeetaoGoooo/SYServer.git
LeetaoGoooo
SYServer
SYServer
master

搜索帮助