-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.deploy.js
39 lines (31 loc) · 960 Bytes
/
app.deploy.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
require('dotenv').config();
const express = require('express');
const cookieParser = require('cookie-parser');
const csrf = require('csurf');
const path = require('path');
const authRouter = require('./routes/auth.routes');
const searchRouter = require('./routes/search.routes');
const app = express();
const port = 3001;
app.use(express.static(path.join(__dirname, '../startop/build')));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(csrf({
cookie: {
key: 'csrf-token',
sameSite: 'strict',
httpOnly: true,
secure: true,
maxAge: 3600 // 1-hour
}
}));
app.use('/api/auth', authRouter);
app.use('/api/search', searchRouter);
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, '../startop/build', 'index.html'));
});
app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`)
});
module.exports = app;