-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (34 loc) · 1.12 KB
/
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
39
40
41
42
43
44
45
require('./db');
require('./auth');
const express = require("express");
const app = express();
const path = require('path');
const passport = require('passport');
// enable sessions
const session = require('express-session');
const sessionOptions = {
secret: 'secret cookie thang (store this elsewhere!)',
resave: true,
saveUninitialized: true
};
app.use(session(sessionOptions));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.resolve(__dirname, "../front-end/build")));
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
// passport setup
app.use(passport.initialize());
app.use(passport.session());
// make user data available to all templates
app.use((req, res, next) => {
res.locals.user = req.user;
next();
});
const playerRoutes = require('./routes/player');
app.use('/api', playerRoutes);
const teamRoutes = require('./routes/team');
app.use('/api', teamRoutes);
const matchRoutes = require('./routes/match');
app.use('/api', matchRoutes);
const PORT = process.env.PORT || 8080;
app.listen(PORT, console.log(`Server started on port ${PORT}`));