import type { Context } from '@oak/oak'; import { type ApiErrorResponseBodyZodSchemaType, type ApiSuccessResponseBodyZodSchemaType, } from '../api/rest-api-response-zod.js'; /** * Returns a successful response to the client * @param ctx Oak context * @param body Success response body */ export function returnOakSuccessResponse(ctx: Context, body: ApiSuccessResponseBodyZodSchemaType): void { ctx.response.status = body.meta.status; ctx.response.body = body; } /** * Set error response on context * @param ctx Oak context * @param errors Array of error objects */ export function returnOakErrorResponse(ctx: Context, body: ApiErrorResponseBodyZodSchemaType): void { ctx.response.status = body.meta.status; ctx.response.body = body; }