feat: infra config module add with get-update-reset functionality

This commit is contained in:
Mir Arif Hasan
2023-11-24 18:55:42 +06:00
parent 74cec0365b
commit c3522025c8
10 changed files with 409 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { PrismaService } from 'src/prisma/prisma.service';
/**
* Load environment variables from the database and set them in the process
*
* @Description Fetch the 'infra_config' table from the database and return it as an object
* (ConfigModule will set the environment variables in the process)
*/
export async function loadInfraConfiguration() {
const prisma = new PrismaService();
const infraConfigs = await prisma.infraConfig.findMany();
let environmentObject: Record<string, any> = {};
infraConfigs.forEach((infraConfig) => {
environmentObject[infraConfig.name] = infraConfig.value;
});
return environmentObject;
}
/**
* Stop the app after 5 seconds
* (Docker will re-start the app)
*/
export function stopApp() {
setTimeout(() => {
process.exit();
}, 5000);
}