-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (47 loc) · 1.37 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
var express = require('express');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var passport = require('passport');
var session = require('express-session');
var app = express();
var port = process.env.PORT || 5000;
var nav = [{
link: '/books',
text: 'Books'
},
{
link: '/authors',
text: 'Authors'
}];
//routers
var bookRouter = require('./src/routes/bookRoutes')(nav);
var adminRouter = require('./src/routes/adminRoutes')(nav);
var authRouter = require('./src/routes/authRoutes')(nav);
//static files
app.use(express.static('public'));
app.set('views', './src/views');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(session({ secret: 'library' }));
require('./src/config/passport')(app);
//views
app.set('view engine', 'ejs');
//routing
app.use('/Books', bookRouter);
app.use('/Admin', adminRouter);
app.use('/Auth', authRouter);
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 on server on port ' + port);
});