generated from ctc-uci/npo-backend-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (30 loc) · 1.01 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
const express = require('express');
const cors = require('cors');
const publishedScheduleRouter = require('./routes/publishedSchedule');
require('dotenv').config();
// routes
const users = require('./routes/users');
const { authRouter } = require('./routes/auth');
const email = require('./routes/nodeMailer');
const app = express();
const catalogRouter = require('./routes/catalog');
const dayRouter = require('./routes/day');
const PORT = process.env.PORT || 3001;
app.use(
cors({
origin: `${process.env.REACT_APP_HOST}:${process.env.REACT_APP_PORT}`,
credentials: true,
}),
);
// app.use(cors({ origin: 'http://localhost:3000', credentials: true }));
// add all routes under here
app.use(express.json()); // for req.body
app.use('/published-schedule', publishedScheduleRouter);
app.use('/users', users);
app.use('/catalog', catalogRouter);
app.use('/nodeMailer', email);
app.use('/auth', authRouter);
app.use('/day', dayRouter);
app.listen(PORT, () => {
console.log(`Server listening on ${PORT}`);
});