-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (24 loc) · 909 Bytes
/
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
/*Getting the modules and assigning them to (constant) objects*/
const express = require('express'),
morgan = require('morgan'),
bodyParser = require('body-parser'),
pug = require('pug'),
fs = require('fs');
/*Storing the paths of the routes */
const userRoutes = require('./routes/users'),
searchRoutes = require('./routes/search');
/*Store express function into a (const) variable*/
const app = express(),
userStore = require('./user-reader');
/**Set the engine to pug */
app.set('view engine', 'pug');
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/users', userRoutes);
app.use('/search', searchRoutes);
app.get('/', (request, response) => {
response.render('index', { users: userStore.getUsers() });
});
app.listen(3000, () => {
console.log('Web Server is running on port 3000');
});