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/db/types.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/lib/server/db/types.ts (limited to 'src/lib/server/db') diff --git a/src/lib/server/db/types.ts b/src/lib/server/db/types.ts new file mode 100644 index 0000000..d842677 --- /dev/null +++ b/src/lib/server/db/types.ts @@ -0,0 +1,5 @@ +import type { LibSQLDatabase } from 'drizzle-orm/libsql'; +import type * as schema from './schema'; + +/** The Drizzle handle a service is built with. */ +export type AppDatabase = LibSQLDatabase; -- cgit v1.3