import Book from '../../data/Book'; const express = require('express'); const router = express.Router(); const settings = require('../../../site/settings.json'); //-------------------------- // Index //-------------------------- router.get('/', function(req, res) { let book = new Book(); book.getPage().then(result => { result.sort((a, b) => parseFloat(b.metadata.id) - parseFloat(a.metadata.id)); let pageData = []; if (req.session.user) { pageData = { title: settings.title, status: true, pages: result }; } else { pageData = { title: settings.title, status: false, pages: result }; } res.render('index', pageData); }); }); //-------------------------- // Logout //-------------------------- router.post('/logout', function(req, res) { req.logout(); return res.json({ message: 'LOGGED OUT' }); }); module.exports = router;