-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
38 lines (31 loc) · 971 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
38
require('./models/user');
var path = require('path');
var express = require('express');
var app = express();
var favicon = require('static-favicon');
var logger = require('morgan');
var session = require('express-session')
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var chatServer = require('./server');
var routes = require('./routes/index');
//express基本配置
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(favicon());
app.use(logger('dev'));
app.use(session({
secret: '1234567890QWERTY'
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
// app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public'), {
maxAge: 86400000
}));
app.use('/', routes);
var server = app.listen(app.get('port'), function() {
console.log('Listening on port %d', server.address().port);
});
chatServer.listen(server);