-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (34 loc) · 1.33 KB
/
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
33
34
35
36
37
38
39
const express = require('express');
const dbConnect = require('./config/dbConnect');
const bodyParser = require("body-parser");
const app = express();
const dotenv = require('dotenv').config();
const PORT = process.env.PORT || 4000;
const authRouter = require('./routes/authRoute');
const productRouter = require('./routes/productRoute');
const blogRouter = require('./routes/blogRoute');
const blogCategoryRouter = require('./routes/blogCategoryRoute');
const productCategoryRouter = require('./routes/productCategoryRoute');
const brandRouter = require('./routes/brandRoute');
const couponRoute = require('./routes/couponRouter');
const { notFound, errorHandler } = require('./middlewares/errorHandler');
const cookieParser = require('cookie-parser');
const morgan = require("morgan");
//Db connection
dbConnect();
app.use(morgan("dev"))
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser())
app.use('/api/user', authRouter);
app.use('/api/product', productRouter);
app.use('/api/blog', blogRouter);
app.use('/api/blog-category', blogCategoryRouter);
app.use('/api/product-category', productCategoryRouter);
app.use('/api/brand', brandRouter);
app.use('/api/coupon', couponRoute)
app.use(notFound);
app.use(errorHandler);
app.listen(PORT, () => {
console.log(`Server is running at port ${PORT}`);
})