ant/web/app.js

58 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// ANT - 蚁逅
//
var route = require("./modules/route"),
logger = require("morgan"),
mailer = require("./modules/mail"),
express = require("express"),
bparser = require("body-parser"),
session = require("express-session");
// 初始化express
var app = express()
// 静态资源路径
app.use(express.static(__dirname + '/bower_components'))
// web日志
app.use(logger('default'))
// 设置模版路径
app.set('views', __dirname + '/views')
// 设置模版引擎
app.set('view engine', 'jade')
// 设置session
app.use(session({
secret: '@nT00R!',
key: 'ANT',
cookie: {
maxAge: 1000 * 60 * 60 * 24 * 10,
httpOnly: true,
path: '/'
},
saveUninitialized: false,
resave: false
}))
// 解析数据包
app.use(bparser.json())
app.use(bparser.urlencoded({
extended: true
}))
app.use(function(req, res, next) {
res.header('Server', 'ANT/1.0');
res.header('X-Powered-By', 'ANT');
next();
})
// 监听端口
var port = process.env.PORT || 3000
// 设置web路由
route(app, app.listen(port));
//app.listen(port);
console.log('[*] ANT listen on port -> ' + port)
// mailer.send({
// to: '[email protected]',
// subject: 'ANT - 服务启动通知',
// html: '通知主人ANT服务已启动!'
// })