-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (26 loc) · 1.01 KB
/
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
35
//Require dependencies
const express = require('express');
const bodyParser = require('body-parser');
const fs = require('fs');
// const cors = require('cors');
const mongoose = require('mongoose');
const app = express();
const port = process.env.PORT || 3000;
// app.use(cors());
app.use(express.json());
//Set pug as view engine
app.set('view engine', 'pug');
//Use static directory (for css, js) and body parser
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/'));
const uri = "mongodb+srv://briefme:briefmeapp@briefmecluster.ylnmc.mongodb.net/briefmedb?retryWrites=true&w=majority&authSource=admin";
mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true });
const connection = mongoose.connection;
connection.once('open', () => {
console.log("MongoDB database connection established successfully");
})
const appRouter = require('./routes/router');
app.use('/', appRouter);
app.listen(port, () => {
console.log(`Server is running on port: ${port}`);
});