Last active 1749835003

Revision d3bf5423ca886efbcb5a23f6b9585e049cafa290

nodeapp.js Raw
1const express = require("express");
2const sellAndBuyRouter = require("./routers/sellAndBuy");
3const bodyParser = require("body-parser");
4require("./mongoose/connect_db/mongoose");
5
6const app = express();
7
8app.use(express.json());
9app.use(bodyParser.json());
10
11app.use((req, res, next) => {
12 res.header("Access-Control-Allow-Origin", "*");
13 res.header("Access-Control-Allow-Headers", "*");
14 if (req.method === "OPTIONS") {
15 res.header("Access-Control-Allow-Methods", "GET,DELETE,PATCH");
16 return res.status(200).json({});
17 }
18 next();
19});
20app.use(sellAndBuyRouter);
21
22module.exports = app;
23
24
25
26
27