CJ_Clippy 87b054e66f
Some checks failed
ci / test (push) Failing after 4m45s
fp/our CI/CD / build (push) Successful in 58s
restrict playback to logged in visitors
2025-11-19 17:46:35 -08:00

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')
}
}
};