mirror of
https://github.com/pupperpowell/bibdle.git
synced 2026-04-05 17:33:31 -04:00
Extracted game state management, share logic, and stats API calls into dedicated modules (game-persistence.svelte.ts, share.ts, stats-client.ts), and moved daily verse loading to client-side to fix timezone issues. Added a guesses column to daily_completions for cross-device state restoration for logged-in users, a new GET /api/stats endpoint, and a staging deploy script. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
682 B
TypeScript
25 lines
682 B
TypeScript
import { json } from '@sveltejs/kit';
|
|
import type { RequestHandler } from './$types';
|
|
import { getVerseForDate } from '$lib/server/daily-verse';
|
|
import { getBookById } from '$lib/server/bible';
|
|
|
|
export const POST: RequestHandler = async ({ request }) => {
|
|
const body = await request.json();
|
|
const { date } = body;
|
|
|
|
if (!date || !/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
return json({ error: 'A valid date (YYYY-MM-DD) is required' }, { status: 400 });
|
|
}
|
|
|
|
const dateStr = date;
|
|
|
|
const dailyVerse = await getVerseForDate(dateStr);
|
|
const correctBook = getBookById(dailyVerse.bookId) ?? null;
|
|
|
|
return json({
|
|
dailyVerse,
|
|
correctBookId: dailyVerse.bookId,
|
|
correctBook,
|
|
});
|
|
};
|