Two new classes have been added: EnvUtils and MongodbService. EnvUtils provides functionality for fetching environment variables and logging them. MongodbService implements connection to MongoDB with user credentials fetched from environment variables. Additionally, some updates have been made to logs.util.ts to improve logging style and biome.json for better code standards adherence.
19 lines
479 B
TypeScript
19 lines
479 B
TypeScript
import * as process from "node:process";
|
|
import { LogsUtils } from "@utils/logs.util";
|
|
|
|
export class EnvUtils {
|
|
private _envs: NodeJS.ProcessEnv;
|
|
private log: LogsUtils;
|
|
|
|
constructor(contextName: string) {
|
|
this.log = new LogsUtils(contextName);
|
|
this._envs = process.env;
|
|
}
|
|
|
|
get(envName: string) {
|
|
const value = this._envs[`${envName.toString()}`]?.toString();
|
|
this.log.debug(`Getting environment variable..`, `${envName} = "${value}"`);
|
|
return value || null;
|
|
}
|
|
}
|