From 0685e9ece66fbcb09c9457027cf7bb2107cc0171 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sun, 18 Oct 2026 22:02:02 +0200 Subject: refactor: inject the database into services via a constructor Pilot on the categories service: a CategoriesService class holds the Drizzle handle, and services/index.ts wires the real instance once for the server while tests build their own on an in-memory database. AppDatabase moves from groceries.ts to db/types.ts. --- src/lib/server/services/groceries.ts | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/lib/server/services/groceries.ts') diff --git a/src/lib/server/services/groceries.ts b/src/lib/server/services/groceries.ts index c56599c..092aba0 100644 --- a/src/lib/server/services/groceries.ts +++ b/src/lib/server/services/groceries.ts @@ -2,12 +2,8 @@ import { db as defaultDb } from '$lib/server/db'; import { groceries, categories, references } from '$lib/server/db/schema'; import { eq, inArray, asc, desc } from 'drizzle-orm'; import { referenceOrder } from './references'; -import type { LibSQLDatabase } from 'drizzle-orm/libsql'; -import type * as schema from '$lib/server/db/schema'; import type { Category, Grocery, Reference } from './types'; -export type AppDatabase = LibSQLDatabase; - export interface EnrichedGrocery extends Grocery { categoryName: string | null; bestRef: Reference | null; -- cgit v1.3