-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (52 loc) · 1.63 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
60
const express = require('express')
const app = express();
const mongoose = require('mongoose');
const session = require('express-session')
const passport = require('passport');
const MS = require('express-mongoose-store')(session, mongoose);
const fileUpload = require('express-fileupload');
const path = require('path');
const csrf = require('csurf')
require('dotenv').config()
require('./config/passport')(passport)
app.use(require('serve-static')('./public'));
app.use(require('cookie-parser')());
app.use(require('body-parser').urlencoded({
extended: true
}));
app.use(session({
secret: process.env.SECRET,
resave: false,
saveUninitialized: false,
store: new MS({
ttl: 63113904000
})
}));
app.use(fileUpload({
useTempFiles: true,
debug: true,
limits: {
fileSize: 500 * 1024 * 1024
},
tempFileDir: path.join(__dirname, '/destroy/tmp/')
}));
app.set('views', 'views');
app.set('view engine', 'ejs');
app.use(passport.initialize());
app.use(passport.session());
app.use('/*', async function (req, res, next) {
console.log(req.method + ' ' + req.originalUrl /*+ ' ' + req.ip*/ )
next()
})
app.use('/', require('./routes/main'))
app.use('/account', require('./routes/account'))
app.use('/app', require('./routes/app'))
app.use('/dev', require('./routes/developer'))
app.use('/developer', require('./routes/docs'))
app.use('/', require('./routes/user'))
mongoose.connect(process.env.MONGO, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
});
app.listen(process.env.PORT, console.log(`${process.env.NAME} is live at http://localhost:${process.env.PORT}`))