-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
34 lines (25 loc) · 804 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
const express = require('express');
const mongoose = require('mongoose');
const helmet = require('helmet');
const cors = require('cors');
const bodyParser = require('body-parser');
const app = express();
require('dotenv').config();
app.use(helmet());
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended : false}));
app.use(express.static(__dirname+'/data/images'));
const MONGODB_URI = process.env.MONGODB_URI;
mongoose.connect(MONGODB_URI,(err,res) => {
if(err){
console.log("Error",err);
}
console.log(`mongodb is connected to ${MONGODB_URI}`)
});
app.use('/',require('./routes/product'));
app.use('/',require('./routes/users'));
const PORT = process.env.PORT;
app.listen(PORT,() => {
console.log(`app is listening to port ${PORT}`);
})