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.
54 lines
1.3 KiB
54 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(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 { gabTV: gabTvService, post: postService } = this.dtp.services;
|
|
try {
|
|
res.locals.gabTvChannel = await gabTvService.getChannelEpisodes('mrjoeprich');
|
|
|
|
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 = async (dtp) => {
|
|
let controller = new HomeController(dtp);
|
|
return controller;
|
|
};
|
|
|