-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (45 loc) · 1.34 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require('express');
var path = require('path');
const mongoose = require('mongoose');
var bodyParser = require('body-parser');
const router = require('./routes/routes');
const app = express();
const port = process.env.PORT || 3000;
app.set('view engine', 'ejs');
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.set("views", path.resolve(__dirname, "views/pages"));
app.use(express.static('public'));
app.get(
'/',(req, res) => {
res.render('index')
});
app.get(
'/createuser',(req, res) => {
res.render('createuser')
});
app.get(
'/updateuser',(req, res) => {
res.render('updateuser')
});
app.get(
'/deleteuser',(req, res) => {
res.render('deleteuser')
});
app.get(
'/latency', (req, res) => {
res.render('latency')
});
app.use('/', router);
//Database
mongoose.connect('mongodb+srv://simencloud:[email protected]/bank?retryWrites=true&w=majority',
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false
});
const db = mongoose.connection;
db.on('error', () => {'Error connecting to the database'});
db.on('open', () => {console.log("We have connection to database")});
app.listen(port, () => console.log(`Express server listening on port ${port}`));