All files / schema-registry/src api.ts

100% Statements 17/17
100% Branches 0/0
100% Functions 8/8
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 531x     1x   7x       1x 1x       1x 1x       1x 1x       1x 1x       1x 1x       1x 1x     1x                            
import { Axios } from '@biorate/axios';
import { ISchemaRegistryConfig } from './interfaces';
 
export const create = (config: ISchemaRegistryConfig) => {
  class SchemaRegistryApi<D = any> extends Axios {
    public baseURL = config.baseURL;
  }
 
  class GetSchemasById extends SchemaRegistryApi {
    public url = '/schemas/ids/:id';
    public method = 'get';
 
    public static fetch(id: string | number, ...args) {
      return this._fetch<string>({ path: { id } }, ...args);
    }
  }
 
  class GetSchemasTypes extends SchemaRegistryApi<string[]> {
    public url = '/schemas/types';
    public method = 'get';
  }
 
  class GetSchemasVersionsById extends SchemaRegistryApi {
    public url = '/schemas/ids/:id/versions';
    public method = 'get';
  }
 
  class GetSubjects extends SchemaRegistryApi {
    public url = '/subjects';
    public method = 'get';
  }
 
  class GetSubjectsVersions extends SchemaRegistryApi {
    public url = '/subjects/:subject/versions';
    public method = 'get';
  }
 
  class DeleteSubjects extends SchemaRegistryApi<{ version: number }[]> {
    public url = '/subjects/:subject';
    public method = 'delete';
  }
 
  return {
    SchemaRegistryApi,
    GetSchemasById,
    GetSchemasTypes,
    GetSchemasVersionsById,
    GetSubjects,
    GetSubjectsVersions,
    DeleteSubjects,
  };
};