use configuration files during runtime

This commit is contained in:
Sven Czarnian
2022-10-22 16:01:39 +02:00
parent cb2b255cc3
commit dfa037cf9d
4 changed files with 28 additions and 14 deletions

View File

@@ -1,7 +1,9 @@
export default () => ({
database: {
url: process.env.DATABASE_URL || 'localhost',
port: parseInt(process.env.DATABASE_PORT, 10) || 27017,
name: process.env.DATABASE_NAME || 'aman',
},
});
import { readFileSync } from 'fs';
import * as yaml from 'js-yaml';
import { join } from 'path';
export default () => {
return yaml.load(
readFileSync(join(__dirname, 'config.yaml'), 'utf8'),
) as Record<string, any>;
};