feat(*): Add improvements to the UX and the data seeding

This commit is contained in:
Josh Creek
2026-01-07 20:13:07 +00:00
parent b9a49686c1
commit 28bb39d558
18 changed files with 1069 additions and 623 deletions
+32
View File
@@ -0,0 +1,32 @@
import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
/**
* GET /api/games
* Returns all games from the games table, sorted by release year descending (newest first)
*/
export const GET: RequestHandler = async ({ locals }) => {
const { supabase } = locals;
try {
// Query games table for all games, sorted by release year descending
const { data, error } = await supabase
.from('games')
.select('displayName, releaseYear')
.order('releaseYear', { ascending: false })
.order('displayName', { ascending: true }); // Secondary sort by name for same year
if (error) {
console.error('Error fetching games:', error);
return json({ error: 'Failed to fetch games' }, { status: 500 });
}
// Extract just the display names
const gameNames = data.map((row) => row.displayName);
return json({ games: gameNames });
} catch (err) {
console.error('Unexpected error fetching games:', err);
return json({ error: 'Internal server error' }, { status: 500 });
}
};