-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (22 loc) · 808 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
const express = require('express');
const mongoose = require('mongoose');
const morgan = require('morgan');
const path = require('path');
const routes = require("./models/routes/api");
const app = express();
const PORT = process.env.PORT || 8080;
//calmlyDemented => password
const MONGODB_URI='mongodb+srv://jensjovellano:calmlyDemented@knowledgereview.frvnxmg.mongodb.net/?retryWrites=true&w=majority';
mongoose.connect(MONGODB_URI,{
useNewUrlParser: true,
useUnifiedTopology: true
});
mongoose.connection.on('connected', () => {
console.log('Mongoose is connected.');
});
app.use(express.json());
app.use(express.urlencoded(({ extended: false})));
// HTTP Request logger
app.use(morgan('tiny'));
app.use('/api', routes);
app.listen(PORT, console.log(`Server is starting at ${PORT}`));