-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { AxiosInstance } from "axios"; | ||
import type { UnknownSharedRoute } from ".."; | ||
import { HandlerCreator } from ".."; | ||
import { ValidationOptions } from "../validations"; | ||
export declare const createAxiosHandlerCreator: <SharedRoutes extends Record<string, UnknownSharedRoute>>(axios: AxiosInstance, options?: ValidationOptions) => HandlerCreator<SharedRoutes>; | ||
export declare const createAxiosSharedClient: <SharedRoutes extends Record<string, UnknownSharedRoute>>(sharedRouters: SharedRoutes, axios: AxiosInstance, validationOptions?: ValidationOptions) => import("..").HttpClient<SharedRoutes>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { createAxiosSharedClient } from "./createAxiosSharedClient"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { z } from "zod"; | ||
import type { ResponsesToHttpResponse, SharedRoute, UnknownResponses, UnknownSharedRoute } from "./defineRoutes"; | ||
import { PathParameters, ReplaceParamsInUrl, Url } from "./pathParameters"; | ||
type EmptyObj = Record<string, never>; | ||
type AnyObj = Record<string, unknown>; | ||
export type HttpResponse<Status extends number | string | symbol, ResponseBody> = { | ||
status: Status; | ||
body: ResponseBody; | ||
headers: Record<string, unknown>; | ||
}; | ||
export type HandlerParams<SharedRoute extends UnknownSharedRoute> = (PathParameters<SharedRoute["url"]> extends EmptyObj ? AnyObj : { | ||
urlParams: PathParameters<SharedRoute["url"]>; | ||
}) & (z.infer<SharedRoute["requestBodySchema"]> extends void ? AnyObj : { | ||
body: z.infer<SharedRoute["requestBodySchema"]>; | ||
}) & (z.infer<SharedRoute["queryParamsSchema"]> extends void ? AnyObj : { | ||
queryParams: z.infer<SharedRoute["queryParamsSchema"]>; | ||
}) & (z.infer<SharedRoute["headersSchema"]> extends void ? AnyObj : { | ||
headers: z.infer<SharedRoute["headersSchema"]>; | ||
}); | ||
export type Handler<SharedRoute extends UnknownSharedRoute> = (params: HandlerParams<SharedRoute> | EmptyObj) => Promise<ResponsesToHttpResponse<SharedRoute["responses"]>>; | ||
export type HttpClient<SharedRoutes extends Record<string, UnknownSharedRoute>> = { | ||
[RouteName in keyof SharedRoutes]: (...params: [SharedRoutes[RouteName], PathParameters<SharedRoutes[RouteName]["url"]>] extends [SharedRoute<Url, void, void, UnknownResponses, void>, EmptyObj] ? [] : [HandlerParams<SharedRoutes[RouteName]>]) => Promise<ResponsesToHttpResponse<SharedRoutes[RouteName]["responses"]>>; | ||
}; | ||
export type HandlerCreator<SharedRoutes extends Record<string, UnknownSharedRoute>> = <R extends keyof SharedRoutes>(routeName: R, routes: SharedRoutes, replaceParamsInUrl: ReplaceParamsInUrl) => Handler<SharedRoutes[R]>; | ||
export declare const configureCreateHttpClient: <S extends Record<string, UnknownSharedRoute>>(handlerCreator: HandlerCreator<S>) => <SharedRoutes extends Record<string, UnknownSharedRoute>>(routes: SharedRoutes) => HttpClient<SharedRoutes>; | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Handler, HttpClient } from "./configureCreateHttpClient"; | ||
import { UnknownSharedRoute } from "./defineRoutes"; | ||
export declare const createCustomSharedClient: <SharedRoutes extends Record<string, UnknownSharedRoute>>(sharedRoutes: SharedRoutes, customHandlers: { [K in keyof SharedRoutes]: Handler<SharedRoutes[K]>; }) => HttpClient<SharedRoutes>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.