-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
49 lines (41 loc) · 1.19 KB
/
server.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
39
40
41
42
43
44
45
46
47
48
49
'use strict';
// require is not really global...
// var originalRequire = require;
// function myRequire(module) {
// console.log(`require("${module})"`);
// return originalRequire(module);
// }
//global.sayWhat = 'huh?';
//global.require = myRequire;
const express = require('express');
const app = express();
const chatCat = require('./app');
const passport = require('passport');
app.set('port', process.env.PORT || 3000);
app.use(express.static('public'));
app.set('views', './views'); // not needed as views is defualt...
app.set('view engine', 'ejs');
app.use((req, res, next) => {
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '0');
next();
});
app.use('/', (req, res, next) => {
console.log(` ${new Date()} - ${req.path}`);
next();
});
app.use(chatCat.session);
app.use(passport.initialize());
app.use(passport.session());
app.use(require('morgan')('combined', {
stream: {
write: message => {
chatCat.logger.log('info', message)
}
}
}));
app.use('/', chatCat.router);
chatCat.ioServer(app).listen(app.get('port'), () => {
console.log(`ChatCat running on port ${app.get('port')}`);
});