-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (26 loc) · 935 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 dotenv = require("dotenv").config();
const connectDb = require("./config/dbConnection");
connectDb();
const app = express();
const port = 4005;
if (process.env.NODE_ENV != "test") {
app.listen(port, () => {
console.log("listening on port " + 4005);
});
}
app.use(function (req, res, next) {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
res.setHeader(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
);
// res.setHeader("Access-Control-Allow-Credentials", true);
next();
});
app.use(express.json());
app.use("/api/v1/inventory/customer", require("./routes/customerRoutes"));
app.use("/api/v1/inventory/vendor", require("./routes/vendorRoutes"));
module.exports = app;