Nth Phonetic Mnemonic

    nest-nacos
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.2 • Public • Published

    nacos

    基于NestJs框架,用于注册Nacos服务、可注入配置

    Usage

    import { Module, OnModuleInit } from "@nestjs/common";
    import { NamingService, NacosModule } from "nest-nacos";
    
    @Module({
      imports: [
        // 可注入获取nacos配置的服务
        NacosModule.forRoot({
          server: process.env.server,
          accessKey: process.env.accessKey,
          secretKey: process.env.secretKey,
          namespace: process.env.namespace,
          config:{
            group: process.env.group,
            dataId: process.env.dataId,
          }
        })
      ]
    })
    
    export class AppModule implements OnModuleInit {
      constructor(private readonly nacos: NacosService) {
      }
    
      async onModuleInit(): Promise<void> {
        // 注册服务名
        await this.nacos.register("service-name");
      }
    }
    

    Keywords

    Install

    npm i nest-nacos

    DownloadsWeekly Downloads

    8

    Version

    0.4.2

    License

    ISC

    Unpacked Size

    18.6 kB

    Total Files

    10

    Last publish

    Collaborators

    • imbooo
    • hehu