-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
39 lines (29 loc) · 909 Bytes
/
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
const express = require('express')
const app = express()
const cors = require('cors')
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
require('dotenv/config')
app.use(cors())
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/uploads/', express.static('uploads'))
const ProductRoute = require('./Routes/Product');
app.use('/products', ProductRoute)
const OrderRoute = require('./Routes/Orders');
app.use('/orders', OrderRoute)
const UserRoute = require('./Routes/User')
app.use('/user', UserRoute)
mongoose.connect(process.env.DB_CONNECTION, { useNewUrlParser: true, useUnifiedTopology: true })
.then(response=>{
console.log("connected")
})
.catch(err=>{
console.error(err)
})
app.use((req, res, next) => {
res.status(200).json({
message: "It works"
});
})
module.exports = app;