use configuration files during runtime

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

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ import Configuration from './config/configuration';
inject: [ConfigService],
useFactory: async (config: ConfigService) => ({
uri: `mongodb://${config.get<string>(
'database.url',
'database.host',
)}:${config.get<number>('database.port')}/${config.get<string>(
'database.name',
)}`,
+9 -7
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>;
};