How to use variable after parse done from env ??
Closed this issue · 2 comments
chungminhtu commented
I don't see any guidance on how to use the variable on class after configify read my .env correct and pass all the validation parser.
tommelo commented
@chungminhtu you mean how to access your configuration?
You can inject the configuration class where is needed in your code and then you access the values: https://github.com/it-gorillaz/configify?tab=readme-ov-file#dependency-injection
E.g.:
export class MyService {
private readonly LOGGER = new Logger(MyService.name);
constructor(private readonly myConfig: MyConfiguration) {}
async useMyConfig(): Promise<void> {
this.LOGGER.log(this.myConfig.anyConfigVariable)
}
}
does this part of the documentation clarify your question?
tommelo commented
Closing due to no further activity on the issue.