fix: use process.cwd() for database path to fix production crash
This commit is contained in:
@@ -2,7 +2,7 @@ import Database from 'better-sqlite3';
|
|||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const dbPath = path.join(__dirname, '../data/database.sqlite');
|
const dbPath = path.join(process.cwd(), 'data/database.sqlite');
|
||||||
const db = new Database(dbPath, { verbose: console.log });
|
const db = new Database(dbPath, { verbose: console.log });
|
||||||
|
|
||||||
const createTables = (): void => {
|
const createTables = (): void => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class DatabaseWrapper {
|
|||||||
private dbPath: string;
|
private dbPath: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dbPath = process.env.DB_PATH || path.join(__dirname, '../data/database.sqlite');
|
this.dbPath = process.env.DB_PATH || path.join(process.cwd(), 'data/database.sqlite');
|
||||||
this.db = new Database(this.dbPath, { verbose: console.log });
|
this.db = new Database(this.dbPath, { verbose: console.log });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user