xtablo-source/apps/api/src/client.ts
2025-11-10 08:52:47 +01:00

37 lines
886 B
TypeScript

/**
* Client type exports for RPC usage
*
* Use this in your frontend or tests for type-safe API calls:
*
* @example
* ```ts
* import { hc } from 'hono/client'
* import type { AppType } from './client'
*
* const client = hc<AppType>('http://localhost:8080')
*
* // Now you get full type safety:
* const res = await client.api.v1.users.me.$get()
* const data = await res.json() // fully typed!
* ```
*/
import { Hono } from "hono";
import type { ApiRoutes } from "./routers/index.js";
import type { getPublicRouter } from "./routers/public.js";
/**
* Main application type for RPC client
* Combines all routes for type-safe client usage
*/
export type AppType = Hono<{
Variables: Record<string, never>;
}> & {
"/api/v1": ApiRoutes;
"/api/public": ReturnType<typeof getPublicRouter>;
};
/**
* Re-export the base API routes type
*/
export type { ApiRoutes };