mirror of
https://github.com/modrinth/code.git
synced 2026-08-27 10:04:52 +00:00
feat: switch to api-client to prevent rate limit errors on game-versions (#5089)
* feat: switch to api-client to prevent rate limit errors on game-versions
* feat: sentry temp
* Revert "feat: sentry temp"
This reverts commit aaa21a3f80.
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
import type { Labrinth } from '@modrinth/api-client'
|
||||
|
||||
import { useServerModrinthClient } from '~/server/utils/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
|
||||
const client = useServerModrinthClient(event)
|
||||
|
||||
const response = await $fetch<Labrinth.Tags.v2.GameVersion[]>(`${apiBaseUrl}tag/game_version`)
|
||||
const response = await client.request<Labrinth.Tags.v2.GameVersion[]>('/tag/game_version', {
|
||||
api: 'labrinth',
|
||||
version: 2,
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
// nitro wont cache if we throw an error
|
||||
if (!response || !Array.isArray(response)) {
|
||||
|
||||
Reference in New Issue
Block a user