Live (In a Volcano) community card game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
1.3 KiB

// home.js
// Copyright (C) 2021 Digital Telepresence, LLC
// License: Apache-2.0
'use strict';
const DTP_COMPONENT_NAME = 'home';
const express = require('express');
const { SiteController } = require('../../lib/site-lib');
class HomeController extends SiteController {
constructor (dtp) {
super(dtp, DTP_COMPONENT_NAME);
}
async start ( ) {
const { dtp } = this;
const { limiter: limiterService } = dtp.services;
const router = express.Router();
dtp.app.use('/', router);
router.use(this.dtp.services.gabTV.channelMiddleware('mrjoeprich'));
router.use(async (req, res, next) => {
res.locals.currentView = 'home';
return next();
});
router.get('/',
limiterService.create(limiterService.config.home.getHome),
this.getHome.bind(this),
);
}
async getHome (req, res, next) {
const { post: postService } = this.dtp.services;
try {
res.locals.pagination = this.getPaginationParameters(req, 20);
res.locals.posts = await postService.getPosts(res.locals.pagination);
res.render('index');
} catch (error) {
return next(error);
}
}
}
module.exports = {
slug: 'home',
name: 'home',
isHome: true,
create: async (dtp) => {
let controller = new HomeController(dtp);
return controller;
},
};