diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-18 22:22:55 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-18 22:22:55 +0200 |
| commit | 4efed80a2f8dc238b420eadf97d56c3eccaadb76 (patch) | |
| tree | 7732a80745622c097a9e75dfb056603bceb10a23 /src/routes/groceries/catalog | |
| parent | 0685e9ece66fbcb09c9457027cf7bb2107cc0171 (diff) | |
refactor: inject the database into every servicemain
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.
Diffstat (limited to 'src/routes/groceries/catalog')
| -rw-r--r-- | src/routes/groceries/catalog/+page.server.ts | 9 |
1 files changed, 3 insertions, 6 deletions
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 }; }, }; |
