forked from bodyno/front-end-separate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (30 loc) · 1005 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var express = require('express');
var vm = require('express-velocity');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var bodyParser = require('body-parser');
var routes = require('./routes/routes');//路由
var app = express();
var dir=process.env.dir||"src";
//设置vm模版
app.engine(".vm", vm({root: __dirname + "/"+dir+"/views"}))
app.set('view engine', 'vm')
app.set("views", __dirname + "/"+dir+"/views")
app.use(logger('dev'));
//是否使用favicon图标--不需要 页面已写
app.use(favicon(__dirname + '/src/static/images/favicon.ico'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(session({
secret: 'ig session',
resave: false,
saveUninitialized: true
}));
app.use(express.static(path.join(__dirname + "/"+dir+"")));
//路由
routes(app);
module.exports = app;