-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (28 loc) · 1.19 KB
/
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
35
36
const express = require('express');
const expressLayouts = require('express-ejs-layouts');
const mongoose = require('mongoose');
const app = express();
const PORT = process.env.PORT || 5000;
app.use(expressLayouts);
//parse form data
app.use(express.urlencoded({ extended: false }))
//register view engine
app.set('view engine', 'ejs');//test
//include assets folder
app.use(express.static('./views/public'));
//Database Settings
const url = "mongodb://localhost:27017/DentalApp"
mongoose.connect(url, { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true });
//first flag => mongodb nodejs driver rewrote the tool it uses to parse db connection string
const connection = mongoose.connection;
//once the connection is open do ...
connection.once('open', () => {
console.log("MongoDb database connection established successfully");
})
//Routes
app.use('/', require('./Backend/routes/index'));
app.use('/users', require('./Backend/routes/users'));
app.use('/appointment', require('./Backend/routes/appointment'))
app.use('/contact', require('./Backend/routes/contact'))
app.use('/about', require('./Backend/routes/about'))
app.listen(PORT, console.log(`Server started on port ${PORT}`));