forked from Afnan-Navaz/pretVA-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (22 loc) · 692 Bytes
/
app.js
File metadata and controls
28 lines (22 loc) · 692 Bytes
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
const express = require('express');
const morgan = require('morgan');
const mongoose = require('mongoose');
const cors = require('cors');
require('dotenv').config();
const product = require('./Routes/products-route');
mongoose.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log('connected to mongoDB'))
.catch(err => console.log(err));
const app = express();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(morgan("dev"));
app.use('/api/products', product);
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`listening on PORT:${PORT}`)
});