diff --git a/src/client.ts b/src/client.ts index 7da832b..eb9e77d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -99,3 +99,5 @@ export const createClient = (options: Cl })) as any; }; }; + +export { type EndpointDefinition, declareEndpoint } from "./shared"; diff --git a/src/index.ts b/src/index.ts index f60159b..8670945 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,3 +8,4 @@ export * from "./context"; export * from "./to-response"; export * from "./helper"; export * from "./standard-schema"; +export { type EndpointDefinition, declareEndpoint } from "./shared"; diff --git a/src/shared.ts b/src/shared.ts new file mode 100644 index 0000000..3a5cd22 --- /dev/null +++ b/src/shared.ts @@ -0,0 +1,27 @@ +/** + * Shared functions for both client and server + */ +import type { EndpointOptions } from "./endpoint"; + +/** + * @experimental + */ +export type EndpointDefinition = { + path: Path; + options: Options; +}; + +/** + * Declare an endpoint without a handler, useful for sharing endpoint definitions between client and server. + * + * @experimental + */ +export function declareEndpoint( + path: Path, + options: Options, +): EndpointDefinition { + return { + path, + options, + }; +}