Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ export const createClient = <R extends Router | Router["endpoints"]>(options: Cl
})) as any;
};
};

export { type EndpointDefinition, declareEndpoint } from "./shared";
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from "./context";
export * from "./to-response";
export * from "./helper";
export * from "./standard-schema";
export { type EndpointDefinition, declareEndpoint } from "./shared";
27 changes: 27 additions & 0 deletions src/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Shared functions for both client and server
*/
import type { EndpointOptions } from "./endpoint";

/**
* @experimental
*/
export type EndpointDefinition<Path extends string, Options extends EndpointOptions> = {
path: Path;
options: Options;
};

/**
* Declare an endpoint without a handler, useful for sharing endpoint definitions between client and server.
*
* @experimental
*/
export function declareEndpoint<Path extends string, Options extends EndpointOptions>(
path: Path,
options: Options,
): EndpointDefinition<Path, Options> {
return {
path,
options,
};
}