-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
49 lines (38 loc) · 1.1 KB
/
Copy pathapp.js
File metadata and controls
49 lines (38 loc) · 1.1 KB
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
const express = require('express');
const chalk = require('chalk');
const debug = require('debug')('app');
const morgan = require('morgan');
const path = require('path');
const app = express();
const port = process.env.PORT || 3000;
app.use(morgan('tiny'));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/css', express.static(path.join(__dirname, '/node_modules/bootstrap/dist/css')));
app.use('/js', express.static(path.join(__dirname, '/node_modules/bootstrap/dist/js')));
app.use('/js', express.static(path.join(__dirname, '/node_modules/jquery/dist')));
app.set('views', './src/views');
app.set('view engine', 'ejs');
const nav = [{
link: '/books',
title: 'Books'
}, {
link: '/authors',
title: 'Authors'
}];
const bookRouter = require('./src/routes/bookRoutes')(nav);
app.use('/books', bookRouter);
app.get('/', (req, res) => {
res.render('index', {
nav: [{
link: '/books',
title: 'Books'
}, {
link: '/authors',
title: 'Authors'
}],
title: 'Library',
});
});
app.listen(port, () => {
debug(`Listenting on port ${chalk.green(port)}`);
});