generated from ctc-uci/npo-backend-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (44 loc) · 1.47 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
46
47
48
49
const express = require('express');
const cors = require('cors');
const cookieParser = require('cookie-parser');
const { authRouter } = require('./routes/auth.router');
const usersRouter = require('./routes/user.router');
const surveysRouter = require('./routes/surveys.router');
const rakersRouter = require('./routes/rakers.router');
const clamsRouter = require('./routes/clams.router');
const computationsRouter = require('./routes/computations.router');
const tablesRouter = require('./routes/tables.router');
const queryRouter = require('./routes/query.router');
const csvRouter = require('./routes/csv.router');
require('dotenv').config();
const app = express();
app.use(express.json());
app.use(
cors({
origin: `${
!process.env.NODE_ENV || process.env.NODE_ENV === 'development'
? process.env.REACT_APP_HOST
: process.env.REACT_APP_PROD_HOST
}`,
credentials: true,
}),
);
app.use(cookieParser());
const PORT =
!process.env.NODE_ENV || process.env.NODE_ENV === 'development'
? 3001
: process.env.REACT_APP_PROD_PORT;
// Routes
app.use('/users', usersRouter);
app.use('/auth', authRouter);
// TODO: Verify tokens after LOFI is done
app.use('/surveys', surveysRouter);
app.use('/clams', clamsRouter);
app.use('/computations', computationsRouter);
app.use('/rakers', rakersRouter);
app.use('/tables', tablesRouter);
app.use('/query', queryRouter);
app.use('/csv', csvRouter);
app.listen(PORT, () => {
console.log(`Server listening on ${PORT}`);
});