26 lines
658 B
JavaScript
26 lines
658 B
JavaScript
// +middleware.js
|
|
// load vods for the vod feed
|
|
|
|
/** @type {import('pocketpages').PageDataLoaderFunc} */
|
|
module.exports = function ({ params, response }, next) {
|
|
try {
|
|
const vods = $app.findRecordsByFilter('vods', null, '-streamDate', 25);
|
|
$app.expandRecords(vods, ["vtubers"], null);
|
|
next({ vods });
|
|
|
|
} catch (e) {
|
|
console.error('error!', e.message);
|
|
|
|
if (e.message.match(/no rows/)) {
|
|
console.error('we are sending 404')
|
|
return response.html(404, 'VODs not found')
|
|
|
|
} else {
|
|
console.error('we are sending error 500')
|
|
return response.html(500, 'Unknown internal error while fetching vods')
|
|
|
|
}
|
|
}
|
|
};
|
|
|