From 662211e1c3295db03192e20dbc88b1d11d315d13 Mon Sep 17 00:00:00 2001 From: Chi Cong Tran Date: Tue, 14 Oct 2025 09:48:04 +0200 Subject: [PATCH] make sure the DB is initiated --- src/lib/server/dbService.ts | 12 +++--------- src/routes/index.ts | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/lib/server/dbService.ts b/src/lib/server/dbService.ts index e91cb4c..d50bee5 100644 --- a/src/lib/server/dbService.ts +++ b/src/lib/server/dbService.ts @@ -1,13 +1,7 @@ import Database from 'better-sqlite3'; -import fs from 'fs'; -import path from 'path'; import { DB_FULLPATH } from '../../routes'; -const fullPath = DB_FULLPATH; -const dir = path.dirname(fullPath); +// make sure the DB is initiated +import '../../init/init_db' -if (!fs.existsSync(dir)) { - fs.mkdirSync(dir); -} - -export const db = new Database(fullPath); +export const db = new Database(DB_FULLPATH); diff --git a/src/routes/index.ts b/src/routes/index.ts index de5bac1..db87d01 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -39,4 +39,4 @@ export const API_ROUTES = { USER: (userId: string) => `/api/users/${userId}` }; -export const DB_FULLPATH = dev ? './src/lib/data/tatort.db' : '/daten/tatort.db' \ No newline at end of file +export const DB_FULLPATH = dev ? './src/lib/data/tatort.db' : '/daten/tatort.db'; \ No newline at end of file