-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (25 loc) · 800 Bytes
/
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
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.urlencoded({extended:true}))
app.use(bodyParser.json())
// Configuring the database
const dbConfig = require('./config/database.config.js')
const mongoose = require('mongoose')
mongoose.connect(dbConfig.url, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
}).then(() => {
console.log("Successfully connected to the database");
}, (err) => {
console.log('Could not connect to the database. Exiting now...', err);
process.exit();
});
app.get('/', (req, res) => {
res.json({"message": "Welcome!"});
});
require('./app/routes/product.routes.js')(app);
app.listen(3000, () => {
console.log("Server is listening");
});