beeeeg update
Some checks failed
Test and deploy staging / staging (push) Has been cancelled

This commit is contained in:
2026-09-23 04:15:10 +00:00
parent 487eff5bb2
commit d0c7b6548b
135 changed files with 9531 additions and 1777 deletions

View File

@@ -1,31 +1,36 @@
import { env } from '$env/dynamic/private';
import { fail } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { listItemCompletions } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import type { PageServerLoad } from './$types';
export const actions = {
authenticate: async ({ request, cookies }) => {
const data = await request.formData();
export const load: PageServerLoad = async ({ locals }) => {
const lists = await db.query.lists.findMany({
columns: { id: true, name: true, slug: true, isProgress: true },
with: { items: { columns: { id: true } } },
orderBy: { id: 'desc' }
});
const token = data.get('token');
if (!token) {
return {
status: 400,
body: { error: 'Missing token' }
};
}
if (token !== env.AUTH_TOKEN) {
return {
status: 401,
body: { error: 'Invalid token' }
};
}
cookies.set('token', token, {
path: '/',
maxAge: 60 * 60 * 24 * 7
});
return {
success: true
};
}
const completed = new Set(
locals.user
? (
await db
.select({ itemId: listItemCompletions.itemId })
.from(listItemCompletions)
.where(eq(listItemCompletions.userId, locals.user.id))
).map((row) => row.itemId)
: []
);
return {
lists: lists.map(({ items, ...list }) => ({
...list,
total: items.length,
checked: list.isProgress ? items.filter((item) => completed.has(item.id)).length : 0
}))
};
};
// Retire the old shared-token login; legacy cookies grant no permissions.
export const actions = {
authenticate: () => fail(410, { message: 'Use the central account login at /login' })
};