Some checks failed
Deploy to Production / test (push) Failing after 33s
- Rewrite AGENTS and README files to match the current app layout - Document API routes, trivia UI, and the active panel design language
2.6 KiB
2.6 KiB
API layer
Server shape
- Aurora uses Bun's native
serve()API inapi/src/server.ts. - Route modules are aggregated in
api/src/routes/index.ts. - A route module returns
nullwhen it does not match so the dispatcher can continue. - After route handling, the server tries
panel/distfor SPA/static files.
Authentication and authorization
- OAuth routes live in
api/src/routes/auth.routes.ts. - Sessions are stored in memory and keyed by the
aurora_sessioncookie. - Session TTL is 7 days.
- Login succeeds only for users already present in the
userstable. - Role is
adminif the Discord ID is inADMIN_USER_IDS, otherwiseplayer. - Redirects after login are intentionally restricted to localhost or relative paths.
Current access rules from api/src/routes/index.ts:
- public:
/auth/*,/api/health - player allow-list:
/api/stats,/api/health,/api/me - everything else under
/api/*: admin-only
/api/me/inventory is handled by users.routes.ts and still depends on a valid session.
Response conventions
jsonResponse()serializesbigintvalues as strings.errorResponse()returns{ error, details? }.parseBody()andparseQuery()validate with Zod and return aResponseon failure.- The API does not use a framework-level middleware stack; each route handles its own parsing and branching.
WebSocket
- Endpoint:
/ws - Requires an authenticated session
- Dashboard channel:
dashboard - Lobby channel:
lobby - Room-specific messaging is handled inside
GameServer - Dashboard broadcasts
STATS_UPDATEevery 5 seconds while clients are connected NEW_EVENTbroadcasts are wired fromshared/lib/events
Hard limits:
- max connections: 200
- max payload: 16 KB
- idle timeout: 60 seconds
Static files
- Built panel assets are served from
panel/dist /assets/*serves files frombot/assets/graphics/api/*,/auth/*,/ws, and/assets/*bypass the SPA fallback
Route notes
items.routes.tssupports both JSON and multipart form data for item creation.settings.routes.tswrites DB-backed game settings and emits the reload-commands event.guild-settings.routes.tsinvalidates the guild config cache after writes.lootdrops.routes.tsdelegates spawning/deletion to bot-side handlers because Discord message creation happens there.
Gotchas
- Sessions and some caches are in-memory only and are lost on restart.
- The server registers game plugins at startup; duplicate registration throws.
- BigInt-safe JSON matters for nearly every domain route.
- The panel's auth flow depends on
PANEL_BASE_URLmatching the OAuth callback origin.