-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.ts
43 lines (29 loc) · 975 Bytes
/
app.ts
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
import express from 'express';
import bodyParser from 'body-parser';
import passport from 'passport';
import next from 'next';
require('dotenv').config();
import './loaders/database';
import session from './loaders/sessions';
import setLocalStrategy from './loaders/passport';
import webSocketStart from './loaders/ws';
import routers from './loaders/routers';
const dev = process.env.NODE_ENV !== 'production';
const nextApp = next({dev});
const nextHandle = nextApp.getRequestHandler();
nextApp.prepare().then(() => {
const app = express();
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
session(app);
setLocalStrategy(passport);
app.use(passport.initialize());
app.use(passport.session());
routers(app);
webSocketStart(app);
app.all('*', (req, res) => {
return nextHandle(req, res);
});
const port = process.env.PORT || 6942;
app.listen(port, () => console.log(`Server started on ${port}`));
});