-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
38 lines (25 loc) · 908 Bytes
/
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
const config = require('./config');
const express = require('express');
const bodyParser = require('body-parser');
const passport = require('passport');
const cors = require('cors');
const path = require('path');
const app = express();
app.set('query parser', 'extended');
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.json());
app.use(cors());
const APIRoute = require('./routes/api/v1');
const authRoute = require('./routes/auth/index');
require('./config/passport')(passport);
app.use(passport.initialize());
// API Routes
app.use('/auth', authRoute);
app.use('/api/v1', APIRoute);
app.use(express.static(path.join(__dirname, "client", "build")));
app.get('*', (_req, res) => {
res.sendFile(path.join(__dirname, "client", "build", "index.html"));
});
app.listen(config.PORT, () => {
console.log(`listening to clients @localhost:${config.PORT} | ✅🎉🚀🚀`);
});