-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
72 lines (57 loc) · 1.54 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var express = require('express');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var app = express();
var port = process.env.PORT || 3000;
var nav = [{
Link: '/Authors',
Text: 'Authors'
},
{
Link: '/Books',
Text: 'Books'
}
];
var bookRouter = require('./src/routes/bookRouter.js')(nav);
var adminRouter = require('./src/routes/adminRoutes.js')(nav);
var authRouter = require('./src/routes/authRoutes.js')(nav);
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(session({ secret: 'library' }));
require('./src/config/passport')(app);
var jade = require('jade');
app.set('views', './src/views');
app.set('view engine', 'ejs');
app.use('/Books', bookRouter);
app.use('/Admin', adminRouter);
app.use('/Auth', authRouter);
app.get('/', function(req, res) {
"use strict";
res.render('index', {
title: 'hello from render',
nav: [{
Link: '/Authors',
Text: 'Authors'
},
{
Link: '/Books',
Text: 'Books'
}
]
});
});
app.get('/books', function(req, res) {
"use strict";
res.send('list of books');
});
app.get('/authors', function(req, res) {
"use strict";
res.send('list of authors');
});
app.listen(5000, function(err) {
"use strict";
console.log('runnig server on port ' + port);
});