aboutsummaryrefslogtreecommitdiff
path: root/src/lib/server/db
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-10-18 22:02:02 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-10-18 22:02:02 +0200
commit0685e9ece66fbcb09c9457027cf7bb2107cc0171 (patch)
treef6dabadf2dcf55f2847a48ada2e03e491f017dcc /src/lib/server/db
parentc3c61894d2b119ae424bac605d4b3099e0b674e5 (diff)
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.
Diffstat (limited to 'src/lib/server/db')
-rw-r--r--src/lib/server/db/types.ts5
1 files changed, 5 insertions, 0 deletions
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<typeof schema>;