9 lines
497 B
JavaScript
9 lines
497 B
JavaScript
import { readFileSync } from 'node:fs';
|
|
const file = process.env.APP_DATABASE_PASSWORD_FILE;
|
|
if (!file) throw new Error('Runtime password file is required.');
|
|
const password = readFileSync(file, 'utf8').trim();
|
|
if (!/^[a-f0-9]{64}$/.test(password)) throw new Error('Invalid runtime password file.');
|
|
const url = new URL('postgresql://kita_runtime@postgres:5432/' + encodeURIComponent(process.env.APP_DATABASE_NAME || 'kita_planer'));
|
|
url.password = password;
|
|
process.stdout.write(url.toString());
|