fix: auto-create database directory using fs and path

This commit is contained in:
2026-02-06 15:22:15 +08:00
parent c6fc32818e
commit 28543f5979
2 changed files with 14 additions and 0 deletions

View File

@@ -1,8 +1,15 @@
import Database from 'better-sqlite3';
import bcrypt from 'bcryptjs';
import path from 'path';
import fs from 'fs';
const dbPath = path.join(process.cwd(), 'data/database.sqlite');
const dbDir = path.dirname(dbPath);
if (!fs.existsSync(dbDir)) {
fs.mkdirSync(dbDir, { recursive: true });
}
const db = new Database(dbPath, { verbose: console.log });
const createTables = (): void => {