From 4be07dcf3424bfa0bd85aea5b024bee9221bf09b Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Wed, 26 Jun 2024 00:43:18 +0800 Subject: [PATCH] feat(route/discourse): Cache site information (#15990) * feat(route/discourse): Cache site information * Update lib/routes/discourse/notifications.ts Co-authored-by: Tony --------- --- lib/routes/discourse/notifications.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/routes/discourse/notifications.ts b/lib/routes/discourse/notifications.ts index 0dff0bfbf..476e9dc9f 100644 --- a/lib/routes/discourse/notifications.ts +++ b/lib/routes/discourse/notifications.ts @@ -2,6 +2,7 @@ import { Route } from '@/types'; import cache from '@/utils/cache'; import { getConfig } from './utils'; import ofetch from '@/utils/ofetch'; +import { config } from '@/config'; export const route: Route = { path: '/:configId/notifications/:fulltext?', @@ -58,7 +59,7 @@ async function handler(ctx) { ); } - const { about } = await ofetch(`${link}/about.json`, { headers: { 'User-Api-Key': key } }); + const { about } = await cache.tryGet(link, async () => await ofetch(`${link}/about.json`, { headers: { 'User-Api-Key': key } }), config.cache.routeExpire, false); return { title: `${about.title} - Notifications`, description: about.description,