feat: add daily win recording endpoint, user authentication, and profile management

- Implemented a POST endpoint for recording daily wins in the game.
- Created login and signup functionality with email and password.
- Developed a profile page allowing users to update their profile information, change passwords, and manage active sessions.
- Added a toggle feature for switching between login and signup forms.
- Enhanced the layout by removing the profile button and adjusting the header structure.
This commit is contained in:
2026-03-01 23:01:44 +01:00
parent e45dfb9832
commit 114f6cde7a
28 changed files with 2603 additions and 31 deletions

View File

@@ -0,0 +1,33 @@
import { json } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { characterHistory } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import { sql } from 'drizzle-orm';
export async function POST({ request }) {
try {
const { characterId } = await request.json();
if (!characterId) {
return json({ error: 'Missing characterId' }, { status: 400 });
}
const today = new Date();
today.setHours(0, 0, 0, 0);
const todayDate = today.toISOString().split('T')[0];
// Increment the won counter for today's entry
await db
.update(characterHistory)
.set({
won: sql`${characterHistory.won} + 1`,
updatedAt: Date.now()
})
.where(eq(characterHistory.date, todayDate));
return json({ success: true });
} catch (error) {
console.error('Error recording win:', error);
return json({ error: 'Failed to record win' }, { status: 500 });
}
}