Files
picobook/src/server/api.ts
T

11 lines
480 B
TypeScript
Raw Normal View History

2023-10-29 19:28:07 +00:00
import type { RouteList } from "./routelist.ts"
type RouteUrl = RouteList[number]["url"];
type HttpMethod = RouteList[number]["method"];
type Route<M extends HttpMethod, U extends RouteUrl> = Extract<RouteList[number], {url: U, method: M}>;
export type RoutePayload<M extends HttpMethod, U extends RouteUrl> = Parameters<Route<M, U>["handler"]>[0]["payload"];
export type RouteResponse<M extends HttpMethod, U extends RouteUrl> = Awaited<ReturnType<Route<M, U>["handler"]>>;