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

1.65.4 • Public • Published

Schema registry

Schema registry connector

Examples:

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { IConnector } from '@biorate/connector';
import {
  SchemaRegistryConnector,
  ISchemaRegistryConnector,
} from '@biorate/schema-registry';

export class Root extends Core() {
  @inject(SchemaRegistryConnector) public connector: ISchemaRegistryConnector;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container
  .bind<ISchemaRegistryConnector>(SchemaRegistryConnector)
  .toSelf()
  .inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

container.get<IConfig>(Types.Config).merge({
  SchemaRegistry: [{ name: 'connection', baseURL: 'http://localhost:8085' }],
});

(async () => {
  const root = container.get<Root>(Root);
  await root.$run();

  const { PostSubjectsVersions } = root.connector.connection('connection');
  const { data } = await PostSubjectsVersions.fetch({
    subject: 'test',
    schema: {
      type: 'record',
      name: 'Test',
      namespace: 'test',
      fields: [
        {
          name: 'firstName',
          type: 'string',
        },
        {
          name: 'lastName',
          type: 'string',
        },
        {
          name: 'age',
          type: 'int',
        },
      ],
    },
  });
  console.log(data); // { id: 1 }
})();

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Package Sidebar

Install

npm i @biorate/schema-registry

Weekly Downloads

9

Version

1.65.4

License

MIT

Unpacked Size

256 kB

Total Files

44

Last publish

Collaborators

  • llevkin