extremely claude-assisted go game based on atproto! working on cleaning up and giving a more unique design, still has a bit of a slop vibe to it.

Update game page to fetch from Constellation instead of database

- Add findGameByRkey() to search for game by rkey
- Remove database dependency from game page
- Fetch game metadata directly from Constellation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

+49 -12
+42
src/lib/atproto-client.ts
··· 641 641 } 642 642 643 643 /** 644 + * Find a game by rkey from Constellation 645 + */ 646 + export async function findGameByRkey(rkey: string): Promise<GameWithMetadata | null> { 647 + try { 648 + const params = new URLSearchParams({ 649 + collection: 'boo.sky.go.game', 650 + limit: '100', // Search through recent games 651 + }); 652 + 653 + const res = await fetch( 654 + `${CONSTELLATION_BASE}/blue.microcosm.records.listRecords?${params}`, 655 + { headers: { Accept: 'application/json' } } 656 + ); 657 + 658 + if (!res.ok) { 659 + console.error('Constellation listRecords failed:', res.status); 660 + return null; 661 + } 662 + 663 + const body = await res.json(); 664 + 665 + for (const rec of body.records || []) { 666 + if (rec.uri) { 667 + const uriParts = rec.uri.split('/'); 668 + const recRkey = uriParts[4]; // Extract rkey from at://did/collection/rkey 669 + 670 + if (recRkey === rkey) { 671 + const did = uriParts[2]; 672 + const gameRecord = rec.value as GameRecord; 673 + 674 + return await calculateGameMetadata(rec.uri, gameRecord, did, rkey); 675 + } 676 + } 677 + } 678 + } catch (err) { 679 + console.error('Failed to find game by rkey from Constellation:', err); 680 + } 681 + 682 + return null; 683 + } 684 + 685 + /** 644 686 * List all game records from a player's PDS 645 687 */ 646 688 export async function listPlayerGames(did: string): Promise<Array<{ uri: string; rkey: string; value: GameRecord }>> {
+7 -12
src/routes/game/[id]/+page.server.ts
··· 1 1 import { error } from '@sveltejs/kit'; 2 2 import type { PageServerLoad } from './$types'; 3 3 import { getSession } from '$lib/server/auth'; 4 - import { getDb } from '$lib/server/db'; 4 + import { findGameByRkey } from '$lib/atproto-client'; 5 5 6 6 export const load: PageServerLoad = async (event) => { 7 7 const session = await getSession(event); 8 8 const { id: rkey } = event.params; 9 9 10 - const db = getDb(); 11 - 12 - const game = await db 13 - .selectFrom('games') 14 - .select(['rkey', 'id', 'player_one', 'player_two', 'board_size', 'status', 'created_at']) 15 - .where('rkey', '=', rkey) 16 - .executeTakeFirst(); 10 + // Fetch game from Constellation 11 + const game = await findGameByRkey(rkey); 17 12 18 13 if (!game) { 19 14 throw error(404, 'Game not found'); ··· 22 17 return { 23 18 session, 24 19 gameRkey: game.rkey, 25 - creatorDid: game.player_one, 26 - playerTwoDid: game.player_two, 27 - gameAtUri: game.id, 28 - boardSize: game.board_size, 20 + creatorDid: game.creatorDid, 21 + playerTwoDid: game.playerTwo || null, 22 + gameAtUri: game.uri, 23 + boardSize: game.boardSize, 29 24 status: game.status, 30 25 }; 31 26 };