Authored by 毕凯

增加默认主页

... ... @@ -33,12 +33,12 @@ app.use(function(req, res, next) {
app.use('/', require('./router'));
// 未知路由转入 404
// app.use(function(req, res) {
// var err = new Error('Not Found');
//
// err.status = 404;
// res.send(404, err);
// });
app.use(function(req, res) {
var err = new Error('Not Found');
err.status = 404;
res.status(404).send(err);
});
// 捕获全局错误, 开发环境返回错误详情
app.use(function(err, req, res) {
... ... @@ -47,6 +47,7 @@ app.use(function(err, req, res) {
} else {
err = {};
}
res.status(err.status || 500);
res.render('error', {
message: err.message,
... ... @@ -54,5 +55,4 @@ app.use(function(err, req, res) {
});
});
module.exports = app;
... ...
... ... @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"start": "node ./bin/www",
"lint": "eslint -c .eslintrc --fix --cache public/**/*.js",
"lint": "eslint -c .eslintrc --fix --cache .",
"validate": "npm ls"
},
"dependencies": {
... ...
... ... @@ -3,14 +3,15 @@
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/3/28
*/
'use stricts';
const express = require('express');
const app = new express.Router();
const routes = './routes';
var index = require(`${routes}/index`);
var wxLottery = require(`${routes}/wxLottery/index`);
app.get('/wxLottery', wxLottery.index);
app.get('/', index.index); // 主页
app.get('/wxLottery', wxLottery.index); // 微信抽奖活动
module.exports = app;
... ...
/**
* 默认主页
*/
exports.index = (req, res) => {
res.send('Hello YOHO!');
};
... ...