Frontend updates: caching basic data (json) from CDragon

Implement caching in the patch_detector, consume the cache from API routes in frontend
This commit is contained in:
2026-02-28 00:23:04 +01:00
parent dc09d10f07
commit fe128c0848
18 changed files with 480 additions and 65 deletions

View File

@@ -0,0 +1,14 @@
import { getChampionSummary } from '~/server/utils/cdragon-cache'
export default defineEventHandler(async () => {
try {
const championSummary = await getChampionSummary()
return championSummary
} catch (error) {
console.error('Error fetching champion summary:', error)
throw createError({
statusCode: 500,
statusMessage: 'Failed to fetch champion summary'
})
}
})

View File

@@ -0,0 +1,14 @@
import { getItems } from '~/server/utils/cdragon-cache'
export default defineEventHandler(async () => {
try {
const items = await getItems()
return items
} catch (error) {
console.error('Error fetching items:', error)
throw createError({
statusCode: 500,
statusMessage: 'Failed to fetch items'
})
}
})

View File

@@ -0,0 +1,14 @@
import { getPerks } from '~/server/utils/cdragon-cache'
export default defineEventHandler(async () => {
try {
const perks = await getPerks()
return perks
} catch (error) {
console.error('Error fetching perks:', error)
throw createError({
statusCode: 500,
statusMessage: 'Failed to fetch perks'
})
}
})

View File

@@ -0,0 +1,14 @@
import { getPerkStyles } from '~/server/utils/cdragon-cache'
export default defineEventHandler(async () => {
try {
const perkStyles = await getPerkStyles()
return perkStyles
} catch (error) {
console.error('Error fetching perk styles:', error)
throw createError({
statusCode: 500,
statusMessage: 'Failed to fetch perk styles'
})
}
})

View File

@@ -0,0 +1,14 @@
import { getSummonerSpells } from '~/server/utils/cdragon-cache'
export default defineEventHandler(async () => {
try {
const summonerSpells = await getSummonerSpells()
return summonerSpells
} catch (error) {
console.error('Error fetching summoner spells:', error)
throw createError({
statusCode: 500,
statusMessage: 'Failed to fetch summoner spells'
})
}
})

View File

@@ -1,11 +1,7 @@
import { CDRAGON_BASE } from '~/utils/cdragon'
import { getChampionSummary } from '~/server/utils/cdragon-cache'
async function championRoutes() {
const championsData: Array<Champion> = await (
await fetch(
CDRAGON_BASE + 'plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json'
)
).json()
const championsData = await getChampionSummary()
const routes: Array<string> = []
for (const champion of championsData) {