fix: working on adding internal postgres database.

This commit is contained in:
charlesgauthereau
2026-02-14 22:23:04 +01:00
parent 12535a59e8
commit b4da6fdd9f
16 changed files with 118 additions and 454 deletions
+10
View File
@@ -39,3 +39,13 @@ export function buildOrganizationWithMembers(
export function getFileExtension(dbType: string) {
switch (dbType) {
case "postgresql":
return ".dump";
case "mysql":
return ".sql";
default:
return ".dump";
}
}
+4 -2
View File
@@ -3,6 +3,7 @@ import path from 'path';
import {generateKeyPair} from 'crypto';
import {promisify} from 'util';
import {randomBytes} from 'crypto';
import {env} from "@/env.mjs";
const generateKeyPairAsync = promisify(generateKeyPair);
@@ -13,9 +14,10 @@ const generateKeyPairAsync = promisify(generateKeyPair);
* @param {string} [dir] path to directory
* @returns {Promise<{privateKeyPath:string, publicKeyPath:string}>}
*/
export async function generateRSAKeys(dir = path.join(process.cwd(), 'private/keys')) {
export async function generateRSAKeys(dir = path.join(env.PRIVATE_PATH, '/keys')) {
await fs.mkdir(dir, {recursive: true});
const privateKeyPath = path.join(dir, 'server_private.pem');
const publicKeyPath = path.join(dir, 'server_public.pem');
@@ -47,7 +49,7 @@ export async function generateRSAKeys(dir = path.join(process.cwd(), 'private/ke
* @param {string} [filePath] Path to store the key
* @returns {Promise<Buffer>} The master key
*/
export async function getOrCreateMasterKey(filePath = path.join(process.cwd(), 'private/keys', 'master_key.bin')) {
export async function getOrCreateMasterKey(filePath = path.join(env.PRIVATE_PATH, '/keys', 'master_key.bin')) {
await fs.mkdir(path.dirname(filePath), {recursive: true});