-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (36 loc) · 1.33 KB
/
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
34
35
36
37
38
39
40
41
const express = require("express");
const helmet = require("helmet");
const config = require("./config");
const {CategoryRoutes,SearchRoutes,UserRoutes,ProductRoutes,OrderRoutes,HomeOfferRoutes,BrandRoutes} = require("./routes");
const events = require("./scripts/events");
const loaders = require("./loaders");
require('./loaders/dbConnect')
var bodyParser = require('body-parser');
const app = express();
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
if (req.method === 'OPTIONS') {
res.header('Access-Control-Allow-Methods', 'PUT, POST, PATCH, DELETE, GET');
return res.status(200).json({});
}
next();
});
config();
loaders();
events();
//app.use("/uploads", express.static(path.join(__dirname, "uploads")));
app.use(helmet());
app.use('/uploads',express.static('uploads'))
app.use(bodyParser.urlencoded({extended:true}))
app.use(bodyParser.json())
app.listen(process.env.APP_PORT, () => {
console.log(`3000 Port Connected`);
app.use("/category", CategoryRoutes);
app.use("/users", UserRoutes);
app.use("/product",ProductRoutes)
app.use("/order",OrderRoutes)
app.use("/homeoffer",HomeOfferRoutes)
app.use("/brand",BrandRoutes)
app.use("/search",SearchRoutes)
});