-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
51 lines (46 loc) · 1.32 KB
/
main.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
var express = require('express'),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
handlebars = require('express-handlebars'),
app = express(),
port = 8888,
json = {
navbar:[
{
name: 'Books',
routes: '/books'
},
{
name: 'Authors',
routes: '/authors'
}
]
};
app.listen(port, function (error) {
if (error) {
console.log(error);
return;
}
console.log('Server Running... Listening on port ' + port);
});
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(session({secret: 'library'}));
require('./src/Config/passport')(app);
app.set('views', './src/Views');
app.set('view engine', '.hbs');
app.engine('.hbs', handlebars({
extname: '.hbs'
}));
var booksRouter = require('./src/Routers/booksRouter')(json.navbar),
adminRouter = require('./src/Routers/adminRouter')(json.navbar),
authRouter = require('./src/Routers/authRouter')();
app.use('/books', booksRouter);
app.use('/admin', adminRouter);
app.use('/auth', authRouter);
app.get('/', function (request, response) {
response.render('index', json);
});