diff --git a/server/src/database/sqlite.ts b/server/src/database/sqlite.ts index ec57d52..46770dd 100644 --- a/server/src/database/sqlite.ts +++ b/server/src/database/sqlite.ts @@ -1,9 +1,14 @@ +import fs from 'fs'; import { verbose } from "sqlite3"; import { validate as validateEmailAddress } from 'email-validator'; import Database from "./index"; const sqlite3 = verbose(); +if (!fs.existsSync('./data')) { + fs.mkdirSync('./data'); +} + const db = new sqlite3.Database('./data/chat.sqlite'); // interface ChatRow { diff --git a/server/src/index.ts b/server/src/index.ts index 1244434..b5ffb48 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -95,12 +95,8 @@ export default class ChatServer { } async initialize() { - if (!fs.existsSync('./data')) { - fs.mkdirSync('./data'); - } - - await this.objectStore.initialize();; - await this.database.initialize();; + await this.objectStore.initialize(); + await this.database.initialize(); try { this.app.listen(port, () => { diff --git a/server/src/object-store/sqlite.ts b/server/src/object-store/sqlite.ts index 04b30b0..c50a55c 100644 --- a/server/src/object-store/sqlite.ts +++ b/server/src/object-store/sqlite.ts @@ -1,8 +1,13 @@ +import fs from 'fs'; import { verbose } from "sqlite3"; import ObjectStore from "./index"; const sqlite3 = verbose(); +if (!fs.existsSync('./data')) { + fs.mkdirSync('./data'); +} + const db = new sqlite3.Database('./data/object-store.sqlite'); export interface StoredObject {