mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 06:12:26 +00:00
Co-authored-by: Github Action <action@github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Brendan Allan <git@brendonovich.dev>
37 lines
832 B
TypeScript
37 lines
832 B
TypeScript
import { resolver } from "hono-openapi"
|
|
import z from "zod"
|
|
import { NotFoundError } from "../storage/db"
|
|
|
|
export const ERRORS = {
|
|
400: {
|
|
description: "Bad request",
|
|
content: {
|
|
"application/json": {
|
|
schema: resolver(
|
|
z
|
|
.object({
|
|
data: z.any(),
|
|
errors: z.array(z.record(z.string(), z.any())),
|
|
success: z.literal(false),
|
|
})
|
|
.meta({
|
|
ref: "BadRequestError",
|
|
}),
|
|
),
|
|
},
|
|
},
|
|
},
|
|
404: {
|
|
description: "Not found",
|
|
content: {
|
|
"application/json": {
|
|
schema: resolver(NotFoundError.Schema),
|
|
},
|
|
},
|
|
},
|
|
} as const
|
|
|
|
export function errors(...codes: number[]) {
|
|
return Object.fromEntries(codes.map((code) => [code, ERRORS[code as keyof typeof ERRORS]]))
|
|
}
|