2 Star 1 Fork 0

zhangrenyang/zhufeng_community

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
zhangrenyang 提交于 2015-01-09 11:16 . 第一版发布
var path = require('path');
var express = require('express');
//var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var MongoStore = require('connect-mongo')(session);
var flash = require('connect-flash');
var multer = require('multer');
var index = require('./routes/index');
var users = require('./routes/users');
var category = require('./routes/category');
var article = require('./routes/article');
var reply = require('./routes/reply');
var settings = require('./settings');
var mongoose = require('mongoose');
mongoose.connect(settings.mongoose);
var fs = require('fs');
var accessLog = fs.createWriteStream('access.log', {flags: 'a'});
var errorLog = fs.createWriteStream('error.log', {flags: 'a'});
var app = express();
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'view'));
app.set('view engine', 'ejs');
//app.use(favicon(__dirname + '/public/images/favicon.ico'));
app.use(logger('dev'));
app.use(logger({stream: accessLog}));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(multer({
dest: './public/images',
rename: function (fieldname, filename) {
return filename;
}
}));
app.use(cookieParser());
app.use(session({
secret: settings.cookieSecret,
key: settings.db,//cookie name
cookie: {maxAge: 1000 * 60 * 60 * 24 * 30},//30 days
store: new MongoStore({
db: settings.db,
host: settings.host,
port: settings.port
})
}));
app.use(flash());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/',index);
app.use('/users', users);
app.use('/category',category);
app.use('/article',article);
app.use('/reply',reply);
/*app.use(function (err, req, res, next) {
var meta = '[' + new Date() + '] ' + req.url + '\n';
errorLog.write(meta + err.stack + '\n');
next();
});*/
app.listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
CSS
1
https://gitee.com/zhangrenyang/zhufeng_community.git
[email protected]:zhangrenyang/zhufeng_community.git
zhangrenyang
zhufeng_community
zhufeng_community
master

搜索帮助