diff --git a/server/globalUtils/routeDefs/responses.ts b/server/globalUtils/routeDefs/responses.ts new file mode 100644 index 0000000..ec3edb7 --- /dev/null +++ b/server/globalUtils/routeDefs/responses.ts @@ -0,0 +1,45 @@ +import {z} from "@hono/zod-openapi"; + +const responseSchema = z.object({ + success: z.boolean().openapi({example: true}), + message: z.string().optional(), + data: z + .array(z.object({}).optional()) + .optional() + .openapi({example: [{data: "hi"}]}), +}); + +export const responses = () => { + return { + 200: { + content: { + "application/json": {schema: responseSchema}, + }, + description: "Response message", + }, + 400: { + content: { + "application/json": { + schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}), + }, + }, + description: "Internal Server Error", + }, + 401: { + content: { + "application/json": { + schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}), + }, + }, + description: "Unauthorized", + }, + 500: { + content: { + "application/json": { + schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}), + }, + }, + description: "Internal Server Error", + }, + }; +};