1.2.1 • Published 9 months ago

@ddboot/config v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@ddboot/logger

Description

config module for Nest

Installation

$ npm i --save @ddboot/config yaml lodash

Quick Start

  • import ConfigModule in your root module
import { Module } from '@nestjs/common';
import { ConfigModule } from '@ddboot/config';
@Module({
  imports: [
    ConfigModule.forRootAsync({
      filePath: '',
      fileName: 'config.yaml',
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
  • use LoggerService in your service
import { Injectable } from '@nestjs/common';
import { InjectConfig, ConfigService } from '@ddboot/config';

@Injectable()
export class AppService {
  //must use @InjectConfig() to inject logger
  constructor(@InjectConfig() private readonly config: ConfigService) {}
  getHello(): string {
    this.config.get('client.id');
    return 'Hello World!';
  }
}
  • or use @Value() decorator in your service
import { Injectable } from '@nestjs/common';
import { Value } from '@ddboot/config';

@Injectable()
export class AppService {
  @Value('client.id')
  private clientId: string;

  getHello(): string {
    this.logger.info('getHello');
    return 'Hello World!';
  }
}

Note: @Value() decorator will inject Logger instance to your service, so you can use this.logger to log. If you want to use @InjectLogger() decorator, you must use this.iLogger.getLogger() to get Logger instance.

Configuration

  • Config
interface Config {
  path?: string;
  level?: string;
  // file name
  name?: string;
  // console show log
  console?: boolean;
}

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

License

@nsboot/logger is MIT licensed.

1.2.0

9 months ago

1.1.3

10 months ago

1.2.1

9 months ago

1.1.2

10 months ago

1.1.1

1 year ago

1.1.0

1 year ago