-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (26 loc) · 719 Bytes
/
Copy pathapp.js
File metadata and controls
31 lines (26 loc) · 719 Bytes
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
import express from "express"
import bodyParser from "body-parser"
import configureRoutes from "./routes"
import ErrorMiddleware from "./middlewares/ErrorMiddleware"
import { PORT } from "./config"
const cors = require("cors")
const app = express()
app.use(bodyParser.json())
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:8080")
res.setHeader(
"Access-Control-Allow-Methods",
"GET, POST"
);
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
})
configureRoutes(app)
app.use(cors());
app.use(ErrorMiddleware)
app.listen(PORT,() => {
console.log(`app is listening to port 5000`);
})