trends: Deno.cron try/catch

This commit is contained in:
Alex Gleason
2024-07-23 22:19:10 -05:00
parent 64eeee5ff7
commit 5ebde99320
2 changed files with 14 additions and 4 deletions

View File

@@ -12,8 +12,12 @@ import { renderStatus } from '@/views/mastodon/statuses.ts';
let trendingHashtagsCache = getTrendingHashtags();
Deno.cron('update trending hashtags cache', '35 * * * *', async () => {
const trends = await getTrendingHashtags();
trendingHashtagsCache = Promise.resolve(trends);
try {
const trends = await getTrendingHashtags();
trendingHashtagsCache = Promise.resolve(trends);
} catch (e) {
console.error(e);
}
});
const trendingTagsQuerySchema = z.object({
@@ -51,8 +55,12 @@ async function getTrendingHashtags() {
let trendingLinksCache = getTrendingLinks();
Deno.cron('update trending links cache', '50 * * * *', async () => {
const trends = await getTrendingLinks();
trendingLinksCache = Promise.resolve(trends);
try {
const trends = await getTrendingLinks();
trendingLinksCache = Promise.resolve(trends);
} catch (e) {
console.error(e);
}
});
const trendingLinksController: AppController = async (c) => {