-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (27 loc) · 823 Bytes
/
app.js
File metadata and controls
34 lines (27 loc) · 823 Bytes
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 path = require('path');
const app = express();
const ejs = require('ejs');
const bodyParser = require('body-parser');
const port = process.env.PORT || 5000;
//require db file
const db = require('./config/db');
//body parser middleware
app.use(bodyParser.text());
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(bodyParser.json());
//set the view engine
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '/views'));
//set up the public folder
app.use('/public', express.static(path.join(__dirname, '/public')));
app.listen(port, () => {
console.log(`listening to server on ${port}`);
db.connect(() => {
console.log('connected to mongodb');
//set the route
app.use('/', require('./routes/todo'));
});
});