File
Blob: worker/src/server/routes/context.ts
| 1 | import type { Context } from 'hono'; |
| 2 | import type { z } from 'zod'; |
| 3 | import { body, parse, rpcResponse } from '@/server/http.ts'; |
| 4 | import type { HttpApp } from '@/server/http.ts'; |
| 5 | |
| 6 | export const room = (c: Context<HttpApp>) => c.env.ROBOTS.getByName(c.env.ROBOT_NAME); |
| 7 | export const result = <T>(c: Context<HttpApp>, value: Parameters<typeof rpcResponse<T>>[0]) => |
| 8 | rpcResponse(value, c.get('requestId')); |
| 9 | export const input = async <T>(c: Context<HttpApp>, schema: z.ZodType<T>) => |
| 10 | parse(schema, await body(c.req.raw)); |