-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.js
38 lines (32 loc) · 1.03 KB
/
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
36
37
38
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const roomRouter = require('./routes/roomRoute');
const liveRouter = require('./routes/liveRoute');
const missionRouter = require('./routes/missionRoute');
const app = express();
const PORT = 8000;
const whiteListCors = ['https://www.jkt48showroom.com/', 'http://localhost:3000']
app.use(cors({
origin: function(origin, cb) {
if(whiteListCors.includes(origin)) {
cb(null, true)
} else {
cb(new Error('Not allowed'))
}
}
}))
app.use(bodyParser.json());
app.listen(PORT, () => {
console.log(`Server Running on port http://localhost:${PORT}`);
});
app.get('/', (req, res) => {
res.send({
message: 'Welcome To JKT48 SHOWROOM API',
author: 'https://github.com/ikhbaldwiyan',
repository: 'https://github.com/ikhbaldwiyan/jkt48-showroom-api'
})
});
app.use('/api/rooms', roomRouter);
app.use('/api/lives', liveRouter);
app.use('/api/missions', missionRouter);