-
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 |
---|---|---|
@@ -1,47 +1,2 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
.vscode | ||
|
||
.DS_Store | ||
|
||
/.yarn_home | ||
/dist | ||
/deno_dist | ||
.idea | ||
.vscode | ||
|
||
/node_modules |
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,25 @@ | ||
import { z } from "zod"; | ||
import type { SharedRoute, UnknownSharedRoute } from "./defineRoutes"; | ||
import { PathParameters, ReplaceParamsInUrl, Url } from "./pathParameters"; | ||
type AnyObj = Record<string, unknown>; | ||
type EmptyObj = Record<string, never>; | ||
export type HttpResponse<ResponseBody> = { | ||
status: number; | ||
body: ResponseBody; | ||
}; | ||
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<HttpResponse<z.infer<SharedRoute["responseBodySchema"]>>>; | ||
export type HttpClient<SharedRoutes extends Record<string, UnknownSharedRoute>> = { | ||
[RouteName in keyof SharedRoutes]: (...params: [SharedRoutes[RouteName], PathParameters<SharedRoutes[RouteName]["url"]>] extends [SharedRoute<Url, void, void, unknown, void>, EmptyObj] ? [] : [HandlerParams<SharedRoutes[RouteName]>]) => Promise<HttpResponse<z.infer<SharedRoutes[RouteName]["responseBodySchema"]>>>; | ||
}; | ||
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>; |