-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
40 lines (33 loc) · 1.23 KB
/
server.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
const express = require('express');
require('dotenv').config()
// connect to mongoDB
const db = require('./config/db')
// initialize express app
const app = express();
// Middlewares
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// link you static folder i.e. images, css
app.use(express.static('public'));
// Routes
const authRoute = require('./routes/auth');
const storeRoute = require('./routes/store');
const productRoute = require('./routes/product');
const userRoute = require('./routes/user');
const categoryRoute = require('./routes/category');
const CartItemRoute = require('./routes/cartItem');
const CartRoute = require('./routes/cart');
const OrderRoute = require('./routes/order');
const OrderItemRoute = require('./routes/orderItem');
app.use('/auth', authRoute);
app.use('/store', storeRoute);
app.use('/product', productRoute);
app.use('/user', userRoute);
app.use('/category', categoryRoute);
app.use('/cartItem', CartItemRoute);
app.use('/cart', CartRoute);
app.use('/order', OrderRoute);
app.use('/orderItem', OrderItemRoute);
// start listening to requests coming from the PORT
const port = process.env.PORT || 3000
app.listen(port, () => console.log(`Server is running on http://localhost:${port}`))