feat: setupDatabase returns host/port/username/password and sets PLUGIN_DB_* env vars

This commit is contained in:
Kyryll O 2026-05-26 23:28:22 +03:00
parent 975fe8ef73
commit 107af7b0f1
1 changed files with 6 additions and 1 deletions

View File

@ -259,9 +259,14 @@ export class CoreService {
throw new Error(`Database setup failed: ${response.statusText}`);
}
const result = await response.json();
const dbName = result.data?.dbName || result.dbName;
const data = result.data || result;
const dbName = data.dbName;
if (!dbName) throw new Error('Database name not returned from core');
process.env.PLUGIN_DB_NAME = dbName;
if (data.host) process.env.PLUGIN_DB_HOST = data.host;
if (data.port) process.env.PLUGIN_DB_PORT = String(data.port);
if (data.username) process.env.PLUGIN_DB_USER = data.username;
if (data.password) process.env.PLUGIN_DB_PASSWORD = data.password;
return dbName;
}
}