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/groceries/catalog/+page.server.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/routes/groceries/catalog') diff --git a/src/routes/groceries/catalog/+page.server.ts b/src/routes/groceries/catalog/+page.server.ts index fd71e30..8d94154 100644 --- a/src/routes/groceries/catalog/+page.server.ts +++ b/src/routes/groceries/catalog/+page.server.ts @@ -1,8 +1,5 @@ import { fail } from '@sveltejs/kit'; -import { - loadAll, - bulkUpdateGroceryCategory, -} from '$lib/server/services/groceries'; +import { groceriesService } from '$lib/server/services'; import { toggleGroceryAction } from '$lib/server/services/grocery-actions'; import { numericId, @@ -18,7 +15,7 @@ export interface CatalogOutput { } export const load: PageServerLoad = async () => { - return loadAll(); + return groceriesService.loadAll(); }; export const actions: Actions = { @@ -34,7 +31,7 @@ export const actions: Actions = { return fail(400, { error: 'Aucun article sélectionné' }); } - await bulkUpdateGroceryCategory(ids, categoryId); + await groceriesService.bulkUpdateGroceryCategory(ids, categoryId); return { success: true, type: 'bulkUpdate' as const }; }, }; -- cgit v1.3