Skip to content

Commit

Permalink
fix: EnvModule now properly loads environment variables when being ac…
Browse files Browse the repository at this point in the history
…cessed
  • Loading branch information
spuxx1701 committed Aug 15, 2024
1 parent e7df43f commit 2a8f661
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/nest-utils/src/env/env.module-mixin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Logger, Module } from '@nestjs/common';
import { plainToInstance } from 'class-transformer';
import { validateSync } from 'class-validator';
import { config } from 'dotenv';

export function EnvModuleMixin<TEnv extends object>(env: new (...args: unknown[]) => TEnv) {
@Module({})
class EnvModule {
static get env(): TEnv {
config();
return plainToInstance(env, process.env, {
enableImplicitConversion: true,
});
Expand Down

0 comments on commit 2a8f661

Please sign in to comment.