fix: add missing GET handler for player purchases

Game client loads purchases via GET /player/:steamId/purchases on
game start but only the POST handler existed, causing 404. Added GET
handler that returns item_ids from the purchases table.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
achmad
2026-05-29 20:43:27 +07:00
parent 78d0b17354
commit 26855bebf5
+7
View File
@@ -93,6 +93,13 @@ route('player/:steamId/currency/give', ['POST'], (ctx: HandlerContext) => {
return { success: true };
});
// GET /player/:steamId/purchases — Get purchase history
route('player/:steamId/purchases', ['GET'], (ctx: HandlerContext) => {
const db = getDb();
const rows = db.prepare('SELECT item_id FROM purchases WHERE steam_id = ? ORDER BY created_at DESC').all(ctx.params.steamId) as any[];
return { purchases: rows.map(r => r.item_id) };
});
// POST /player/:steamId/purchases — Record a store purchase
route('player/:steamId/purchases', ['POST'], (ctx: HandlerContext) => {
const { item_id, item_category, card_id, price_free, price_donate, price_dust } = ctx.body as any;