@intuitionrobotics/thunderstorm
Version:
31 lines (30 loc) • 862 B
TypeScript
export declare enum HttpMethod {
ALL = "all",
POST = "post",
GET = "get",
PATCH = "patch",
DELETE = "delete",
PUT = "put",
OPTIONS = "options",
HEAD = "head"
}
export type QueryParams = {
[key: string]: string | undefined;
};
export type ApiTypeBinder<U extends string | void, R, B, P extends QueryParams | {}, E = any> = {
url: U;
response: R;
body: B;
queryParams: P;
error: E;
};
export type ApiWithBody<U extends string, B, R, E = any> = ApiTypeBinder<U, R, B, {}, E>;
export type ApiWithQuery<U extends string, R, P extends QueryParams | {} = {}, E = any> = ApiTypeBinder<U, R, void, P, E>;
export type ErrorBody<E extends object | void = void> = {
type: string;
body: E;
};
export type ErrorResponse<E extends object | void = void> = {
debugMessage?: string;
error?: ErrorBody<E>;
};