Založení složky server/data, pokud neexistuje, do které je vytvořen soubor db.json
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
import JSONdb from 'simple-json-db';
|
||||
import { StorageInterface } from "./StorageInterface";
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const db = new JSONdb('../data/db.json');
|
||||
const dbPath = path.resolve(__dirname, '../../data/db.json');
|
||||
const dbDir = path.dirname(dbPath);
|
||||
|
||||
// Zajistěte, že adresář existuje
|
||||
if (!fs.existsSync(dbDir)) {
|
||||
fs.mkdirSync(dbDir, { recursive: true });
|
||||
}
|
||||
|
||||
const db = new JSONdb(dbPath);
|
||||
/**
|
||||
* Implementace úložiště používající JSON soubor.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user