-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (27 loc) · 1.03 KB
/
Copy pathapp.js
File metadata and controls
31 lines (27 loc) · 1.03 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
const express = require('express');
const chalk = require('chalk');
const debug = require('debug')('app');
const morgan = require('morgan');
const path = require('path');
const nav = [{ title: 'books', link: '/books' },
{ title: 'Authors', link: '/authors' }];
const app = express();
const bookRouter = require('./src/routes/bookRoutes')(nav);
app.use('/books', bookRouter);
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');
app.get('/', (req, res) => {
res.render('index', {
nav: [{ title: 'books', link: '/books' },
{ title: 'Authors', link: '/authors' }],
title: 'library',
});
});
app.listen('3000', () => {
debug(`listening from port ${chalk.green('3000')}`);
});