-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (24 loc) · 753 Bytes
/
Copy pathapp.js
File metadata and controls
32 lines (24 loc) · 753 Bytes
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
const express = require('express');
const corsMiddleware = require('cors');
const connectionDB = require('./src/db/mongodb');
const rootRout = require('./src/components');
const passport = require('passport');
const corsOptions = {
exposedHeaders: 'X-Auth-Token',
};
// Start DB
connectionDB();
const app = express();
// Root routs
app.use(express.json());
app.use(corsMiddleware(corsOptions));
app.use(express.urlencoded({extended: true}));
app.use(express.static('./build'));
app.use(passport.initialize());
require('./src/auth/config/google')(passport);
app.use('/api', rootRout);
/* final catch-all route to index.html defined last */
app.get('/*', (req, res) => {
res.sendFile(__dirname + '/build/index.html');
})
module.exports = app;