feat(route/discourse): Cache site information (#15990)

* feat(route/discourse): Cache site information

* Update lib/routes/discourse/notifications.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

---------
This commit is contained in:
Andvari
2024-06-26 00:43:18 +08:00
committed by GitHub
co-authored by Tony
parent e94969b9b1
commit 4be07dcf34
+2 -1
View File
@@ -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,