-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (26 loc) · 826 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
const express = require('express');
const mongoose = require('mongoose');
require('dotenv').config();
const app = express();
const authRouter = require('./routes/auth');
const userRoute = require('./routes/user');
const productRoute = require('./routes/product');
const cartRoute = require('./routes/cart');
const orderRoute = require('./routes/order');
app.use(express.json());
app.use('/api/v1/auth',authRouter);
app.use('/api/v1/user',userRoute);
app.use('/api/v1/products',productRoute);
app.use('/api/v1/cart',cartRoute);
app.use('/api/v1/order',orderRoute);
mongoose.connect(process.env.mongo_url)
.then(()=>{
console.log("connected to remote DB");
app.listen(process.env.PORT || 3000,()=>{
console.log("server listening at port 3000...");
})
})
.
catch(err =>{
console.log("Error connecting to DB");
})