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

0.6.0 • 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");
  }
}

/nest-nacos/

    Package Sidebar

    Install

    npm i nest-nacos

    Weekly Downloads

    3

    Version

    0.6.0

    License

    ISC

    Unpacked Size

    20.4 kB

    Total Files

    12

    Last publish

    Collaborators

    • imbooo
    • hehu