0.1.56 • Published 2 years ago

@microservice-stack/nest-config v0.1.56

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Config

This library wraps the default @nestjs/config library and adds the ability to define variables that are required for the service to launch and the ability to parse environment variables.

import { Module } from '@nestjs/common';
import { ConfigModule } from '@microservice-stack/nest-config';

@Module({
  imports: [
    ConfigModule.register({
      requiredEnvironmentVariables: [
        'STRING_VARIABLE',
        'JSON_VARIABLE',
      ],
      parse: (configVariable, value) => {
        if (configVariable === 'JSON_VARIABLE') {
          return JSON.parse(value);
        }

        return value;
    }),
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}

The ConfigModule is registered globally, so you can inject it as you wish

import { ConfigService } from '@microservice-stack/nest-config';

export class AppService {
  constructor(private configService: ConfigService) {}
    
  public hello(): string {
    return this.configService.get('STRING_VARIABLE');
  }
}
0.1.55

2 years ago

0.1.56

2 years ago

0.1.52

3 years ago

0.1.53

3 years ago

0.1.54

3 years ago

0.1.51

3 years ago

0.1.50

3 years ago

0.1.47

3 years ago

0.1.46

3 years ago

0.1.45

3 years ago

0.1.44

3 years ago

0.1.43

3 years ago

0.1.42

3 years ago

0.1.39

3 years ago

0.1.38

3 years ago

0.1.37

3 years ago

0.1.36

3 years ago

0.1.35

3 years ago

0.1.34

3 years ago

0.1.33

3 years ago

0.1.32

3 years ago

0.1.31

3 years ago

0.1.30

3 years ago

0.1.29

3 years ago

0.1.28

3 years ago

0.1.27

3 years ago

0.1.26

3 years ago