@n1k1t/mock-server
Version:
Powerful util to setup mocks over HTTP APIs
23 lines • 1.12 kB
TypeScript
import type { AxiosInstance } from 'axios';
import type { SetPartialKeys, TFunction } from '../../../types';
import type { Provider } from '../../server/models';
type THandler<TContext, TSchema extends IClientMethodSchema> = TFunction<TFunction<Promise<TSchema['outgoing']>, [TSchema['incoming']]>, [
TContext
]>;
export interface IClientMethodSchema {
incoming?: unknown;
outgoing?: unknown;
}
export interface IClientMethodHandlers<TSchema extends IClientMethodSchema> {
remote: THandler<AxiosInstance, TSchema>;
onsite: THandler<SetPartialKeys<Provider, 'server'>, TSchema>;
}
export declare class ClientMethod<TSchema extends IClientMethodSchema> {
TSchema: TSchema;
private handlers;
register<K extends keyof IClientMethodHandlers<any>>(type: K, handler: IClientMethodHandlers<TSchema>[K]): this;
compile<K extends keyof IClientMethodHandlers<any>>(type: K, context: Parameters<IClientMethodHandlers<TSchema>[K]>[0]): TFunction<Promise<any>, [any]>;
static build<TSchema extends IClientMethodSchema>(): ClientMethod<TSchema>;
}
export {};
//# sourceMappingURL=method.d.ts.map