@goopen/nestjs-schema-registry
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published
NestJS Confluent Schema Registry

NestJS module for Confluent Schema Registry


Tiny NestJS module to use with Confluent Schema Registry

1. Install

npm install @goopen/nestjs-schema-registry @kafkajs/confluent-schema-registry

2. Register the Confluent schema module in your app

@Module({
  imports: [
    SchemaRegistryModule.register({
      isGlobal: true,
      host: SCHEMA_REGISTRY_URL,
      auth: {
        username: SCHEMA_REGISTRY_USERNAME,
        password: SCHEMA_REGISTRY_PASSWORD,
      },
    }),
  ],
})
export class KafkaModule {}

Or if you wish to inject the ConfigModule to pull the configuration from environment variables

@Module({
  imports: [
    ConfigModule.forRoot(),
    SchemaRegistryModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        host: configService.get<string>('SCHEMA_REGISTRY_URL'),
        auth: {
          username: configService.get<string>('SCHEMA_REGISTRY_USERNAME'),
          password: configService.get<string>('SCHEMA_REGISTRY_PASSWORD'),
        },
      }),
    }),
  ]
})
export class KafkaModule {}

3. You're then able to use the injector to use the schema registry

@Injectable()
export class KafkaService{
  constructor(
    @InjectSchemaRegistry() private readonly schemaRegistry: SchemaRegistry,
  ) {}
}

Readme

Keywords

none

Package Sidebar

Install

npm i @goopen/nestjs-schema-registry

Weekly Downloads

674

Version

1.1.1

License

BSD

Unpacked Size

108 kB

Total Files

21

Last publish

Collaborators

  • alko89