var express = require('express'); var router = express.Router(); var Models = require('../../models'); var config = require('../../../site-settings.json'); module.exports = function (session) { //-------------------------- // Index //-------------------------- router.get('/:page?', function (req, res) { if (req.params.page == null || req.params.page == "") { Models.FolioProject.findAll({ limit: 5, order: [ ['id', 'DESC'] ] }).then(entries => { Models.Post.findAll({ limit: 5, order: [ ['id', 'DESC'] ] }).then(posts => { Models.Bookmark.findAll({ limit: 5, order: [ ['id', 'DESC'] ] }).then(saved => { res.render(config.theme + '/index', { theme: config.theme, title: 'The Twelfth House | Home of creative technologist, beat maker and over-thinker, Ro', user_status: "What up, random person", mode: 'index', folio: entries, posts: posts, bookmarks: saved }); }).catch(err => { console.log(err); }) }) }).then(function (value) { //console.log(value); }).catch(function (err) { console.log(err); }) } else { switch (req.params.page) { case "dashboard": console.log('here') break; default: console.log(req.params.page) break; } } }); return router; }