-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (28 loc) · 838 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
require("dotenv").config();
const cors = require("cors");
const express = require("express");
const app = express();
const PORT = process.env.PORT || 8000;
// Routes
const detector = require("./routes/detector.routes");
const scanner = require("./routes/scanner.routes.js");
// set up
app.use(cors());
app.use(express.json());
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
);
res.setHeader(
"Access-Control-Allow-Methods",
"GET, POST, PATCH, DELETE, OPTIONS, PUT"
);
next();
});
app.use("/api/detector", detector);
app.use("/api/scanner", scanner);
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}`);
});