-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (34 loc) · 833 Bytes
/
app.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
var express = require('express');
var app = express();
var port = process.env.PORT || 5000;
var nav = [{
Link:'/Books',
Text: 'Book'
},
{
Link:'/Authors',
Text:'Author'
}];
var bookRouter = require('./src/routes/bookRoutes')(nav);
var adminRouter = require('./src/routes/adminRoutes')(nav);
app.use(express.static('public'));
app.set('views', './src/views');
app.set('view engine', 'ejs');
app.use('/Books', bookRouter);
app.use('/Admin', adminRouter);
app.get('/', function(req, res){
res.render('index', {
title: 'Hello from render',
nav: [{
Link:'/Books',
Text: 'Books'
},
{
Link:'/Authors',
Text:'Authors'
}]
});
});
app.listen(port, function(err){
console.log('running server on port' + port);
});