You've already forked AstralRinth
forked from didirus/AstralRinth
Make game versions update every 10 minutes via server-side route (#4892)
This commit is contained in:
17
apps/frontend/src/plugins/update-game-versions.ts
Normal file
17
apps/frontend/src/plugins/update-game-versions.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { Labrinth } from '@modrinth/api-client'
|
||||
|
||||
export default defineNuxtPlugin(async () => {
|
||||
try {
|
||||
const gameVersions = await $fetch<Labrinth.Tags.v2.GameVersion[]>('/api/tags/game-versions')
|
||||
|
||||
if (gameVersions && gameVersions.length > 0) {
|
||||
const state = useState<{ gameVersions: Labrinth.Tags.v2.GameVersion[] }>('generatedState')
|
||||
|
||||
if (state.value) {
|
||||
state.value.gameVersions = gameVersions
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Game Version Updater] Failed to fetch:', error)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user