-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
35 lines (28 loc) · 972 Bytes
/
index.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
import express from 'express';
import dotenv from 'dotenv';
dotenv.config();
import cors from 'cors';
import './db.js';
import applicantRoutes from './src/routes/ApplicantRoutes.js';
import memberRoutes from './src/routes/MemberRoutes.js';
import loginRoutes from './src/routes/LoginRoutes.js';
import utilsRoutes from './src/routes/UtilsRoutes.js';
const PORT = process.env.PORT;
const app = express();
app.use(express.json());
let corsOptions = {
origin : process.env.ORIGIN_URI,
methods: ['GET', 'POST', 'PUT'],
allowedHeaders: ['Content-Type', 'Access-Control-Allow-Origin', 'Access-Control-Allow-Headers']
};
app.use(cors(corsOptions));
app.use('/applicants', applicantRoutes);
app.use('/members', memberRoutes);
app.use('/login', loginRoutes);
app.use('/utils', utilsRoutes);
app.get('/', (req, res) => {
res.json({
message: 'Welcome to Polar Backend'
});
});
app.listen(PORT, () => console.log(`Server running on PORT ${PORT}`));