import { ResolveParams } from '@tanstack/router-core'; export type StartAPIHandlerCallback = (ctx: { request: Request; }) => Response | Promise; export type StartAPIMethodCallback = (ctx: { request: Request; params: ResolveParams; }) => Response | Promise; declare const HTTP_API_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]; export type HTTP_API_METHOD = (typeof HTTP_API_METHODS)[number]; /** * * @param cb The callback function that will be called when the API handler is invoked * @returns The response from the callback function */ export declare function createStartAPIHandler(cb: StartAPIHandlerCallback): import('h3').EventHandler>; type APIRoute = { path: TPath; methods: Partial>>; }; type CreateAPIRouteFn = (methods: Partial>>) => APIRoute; type CreateAPIRoute = (path: TPath) => CreateAPIRouteFn; /** * This function is used to create an API route that will be listening on a specific path when you are not using the file-based routes. * * @param path The path that the API route will be listening on. You need to make sure that this is a valid TanStack Router path in order for the route to be matched. This means that you can use the following syntax: * /api/foo/$bar/name/$ * - The `$bar` is a parameter that will be extracted from the URL and passed to the handler * - The `$` is a wildcard that will match any number of segments in the URL * @returns A function that takes the methods that the route will be listening on and returns the API route object */ export declare const createAPIRoute: CreateAPIRoute; /** * This function is used to create an API route that will be listening on a specific path when you are using the file-based routes. * * @param filePath The path that the API file route will be listening on. This filePath should automatically be generated by the TSR plugin and should be a valid TanStack Router path * @returns A function that takes the methods that the route will be listening on and returns the API route object */ export declare const createAPIFileRoute: CreateAPIRoute; /** * You should only be using this function if you are not using the file-based routes. * * * @param opts - A map of TSR routes with the values being the route handlers * @returns The handler for the incoming request * * @example * ```ts * // app/foo.ts * import { createAPIRoute } from '@tanstack/start-api-routes' * const fooBarRoute = createAPIRoute('/api/foo/$bar')({ * GET: ({ params }) => { * return new Response(JSON.stringify({ params })) * } * }) * * // app/api.ts * import { * createStartAPIHandler, * defaultAPIRoutesHandler * } from '@tanstack/start-api-routes' * * export default createStartAPIHandler( * defaultAPIRoutesHandler({ * '/api/foo/$bar': fooBarRoute * }) * ) * ``` */ export declare const defaultAPIRoutesHandler: (opts: { routes: { [TPath in string]: APIRoute; }; }) => StartAPIHandlerCallback; /** * This function is the default handler for the API routes when using file-based routes. * * @param StartAPIHandlerCallbackContext * @returns The handler for the incoming request * * @example * ```ts * // app/api.ts * import { * createStartAPIHandler, * defaultAPIFileRouteHandler * } from '@tanstack/start-api-routes' * * export default createStartAPIHandler(defaultAPIFileRouteHandler) * ``` */ export declare const defaultAPIFileRouteHandler: StartAPIHandlerCallback; export {};