From 4efed80a2f8dc238b420eadf97d56c3eccaadb76 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sun, 18 Oct 2026 22:22:55 +0200 Subject: refactor: inject the database into every service Groceries, projects, references and routines become classes holding the Drizzle handle, wired once in services/index.ts alongside categories. Tests build their own instance on an in-memory database. Drops the unused projects.loadAll and projects.rename. --- src/routes/+page.server.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/routes/+page.server.ts') diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 008f7f3..ac00aeb 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,12 +1,11 @@ import { fail } from '@sveltejs/kit'; -import { loadOverview } from '$lib/server/services/routines'; -import { add as addProject } from '$lib/server/services/projects'; +import { projectsService, routinesService } from '$lib/server/services'; import { parseFormString } from '$lib/server/services/validation'; import { isUniqueViolation } from '$lib/server/db/errors'; import type { Actions, PageServerLoad } from './$types'; export const load: PageServerLoad = async () => { - return loadOverview(Temporal.Now.instant()); + return routinesService.loadOverview(Temporal.Now.instant()); }; export const actions: Actions = { @@ -16,7 +15,7 @@ export const actions: Actions = { return fail(400, { error: 'Le nom est requis' }); } try { - await addProject(name); + await projectsService.add(name); } catch (error) { if (isUniqueViolation(error)) { return fail(400, { error: 'Ce projet existe déjà' }); -- cgit v1.3