generated from ctc-uci/npo-backend-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (30 loc) · 964 Bytes
/
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
const express = require('express');
const cors = require('cors');
const dog = require('./routes/dog');
require('dotenv').config();
const facilityRouter = require('./routes/facility');
const usersRouter = require('./routes/users');
const facilityContactsRouter = require('./routes/facilityContacts');
const app = express();
const PORT =
!process.env.NODE_ENV || process.env.NODE_ENV === 'development'
? 3001
: process.env.REACT_APP_PROD_PORT;
app.use(
cors({
origin: `${
!process.env.NODE_ENV || process.env.NODE_ENV === 'development'
? `${process.env.REACT_APP_HOST}:${process.env.REACT_APP_PORT}`
: process.env.REACT_APP_PROD_HOST
}`,
credentials: true,
}),
);
app.use(express.json());
app.use('/dog', dog);
app.use('/users', usersRouter);
app.use('/facility', facilityRouter);
app.use('/facilityContacts', facilityContactsRouter);
app.listen(PORT, () => {
console.log(`Server listening on ${PORT}`);
});