-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
34 lines (26 loc) · 1014 Bytes
/
server.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
const express = require("express");
const bodyParser = require("body-parser");
const app = express();
const cors = require("cors");
var corsOptions = {
origin: ["http://localhost:8080", "http://localhost:8081"]
};
app.use(cors(corsOptions));
// parse requests of content-type - application/json
app.use(bodyParser.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
next();
});
app.get("/", (req, res) => {
res.json({ message: "Welcome to the Oncosplice Web Application backend." });
});
require("./app/routes/cancerdata.routes.js")(app);
const PORT = process.env.PORT || 8081;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});