Make game versions update every 10 minutes via server-side route (#4892)

This commit is contained in:
Prospector
2025-12-11 16:05:31 -08:00
committed by GitHub
parent f49f889536
commit 0de780b7c9
2 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import type { Labrinth } from '@modrinth/api-client'
const CACHE_MAX_AGE = 60 * 10 // 10 minutes
export default defineCachedEventHandler(
async (event) => {
const config = useRuntimeConfig(event)
const apiBaseUrl = config.apiBaseUrl || config.public.apiBaseUrl
return await $fetch<Labrinth.Tags.v2.GameVersion[]>(`${apiBaseUrl}tag/game_version`)
},
{
maxAge: CACHE_MAX_AGE,
name: 'game-versions',
getKey: () => 'game-versions',
},
)