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/+page.server.ts | |
| 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/+page.server.ts')
| -rw-r--r-- | src/routes/+page.server.ts | 7 |
1 files changed, 3 insertions, 4 deletions
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à' }); |
