Expand website and game trackers
Some checks failed
Test and deploy staging / staging (push) Failing after 5m29s

This commit is contained in:
2026-09-25 22:43:04 +00:00
parent f6b34150d4
commit c2ba8febb4
4076 changed files with 97237 additions and 1453 deletions

View File

@@ -0,0 +1,32 @@
import { json, error } from '@sveltejs/kit';
import { and, asc, eq } from 'drizzle-orm';
import { db } from '$lib/server/db';
import { pokemon, pokemonEncounters } from '$lib/server/db/schema';
export async function GET({ url }) {
const gameId = Number(url.searchParams.get('game'));
const locationId = Number(url.searchParams.get('location'));
if (![gameId, locationId].every((n) => Number.isSafeInteger(n) && n > 0 && n <= 2147483647))
error(400, 'Invalid game or location');
const rows = await db
.select({
pokemonId: pokemon.id,
number: pokemon.number,
name: pokemon.name,
type1: pokemon.type1,
type2: pokemon.type2,
area: pokemonEncounters.area,
method: pokemonEncounters.method,
minLevel: pokemonEncounters.minLevel,
maxLevel: pokemonEncounters.maxLevel,
rarity: pokemonEncounters.rarity,
conditions: pokemonEncounters.conditions,
form: pokemonEncounters.form,
note: pokemonEncounters.note
})
.from(pokemonEncounters)
.innerJoin(pokemon, eq(pokemon.id, pokemonEncounters.pokemonId))
.where(and(eq(pokemonEncounters.gameId, gameId), eq(pokemonEncounters.locationId, locationId)))
.orderBy(asc(pokemon.number), asc(pokemonEncounters.method), asc(pokemonEncounters.minLevel));
return json(rows, { headers: { 'Cache-Control': 'public, max-age=3600' } });
}