-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (28 loc) · 867 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
const express = require("express");
const bodyParser = require("body-parser");
const cors = require('cors')
const { postPoll, postVote, getPollRequest } = require("./controllers");
const makeCallback = require("./express-callback");
const { frontendUrl } = require("./config/prod");
const PORT = process.env.PORT || 4000;
const app = express();
app.use(cors({
origin: frontendUrl,
methods: ["GET", "POST"],
credentials : true
}));
const httpServer = require("http").createServer(app);
require("./sockets/index")(httpServer,{
cors: {
origin: frontendUrl,
methods: ["GET", "POST"],
credentials : true
}
});
app.use(bodyParser.json());
app.post("/poll", makeCallback(postPoll));
app.get("/get-poll/:id", makeCallback(getPollRequest))
httpServer.listen(PORT, () => {
console.log("Server is listening at " + PORT);
});
module.exports = app;