nest-log

测试nestjs模块包发布

Usage no npm install needed!

<script type="module">
  import nestLog from 'https://cdn.skypack.dev/nest-log';
</script>

README

本包纯属是测试自己发布Nestjs包的方式,没任何功能点,如果你还不会发布Nestjs包的可以学习下

使用方式

  • 1、安装包

    npm install nest-log
    
  • 2、在需要使用的模块中引入

    import { NestLogModule } from 'nest-log';
    
    @Module({
      imports: [
        // 使用自己刚刚发布的npm包
        NestLogModule.register('test---')
      ],
      providers: [UsersService],
      controllers: [UsersController]
    })
    export class UsersModule { }
    
  • 3、在控制器中使用服务

    import { Controller, Get } from '@nestjs/common';
    import { NestLogService } from 'nest-log';
    
    @Controller('users')
    export class UsersController {
      constructor (
        private readonly nestLogService: NestLogService,
      ) { }
    
      @Get()
      hello(): string {
        this.nestLogService.log('获取用户信息')
        return 'hello';
      }
    }