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
parent e94969b9b1
commit 4be07dcf34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

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,