import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi"; import { responses } from "../../../globalUtils/routeDefs/responses.js"; import { tryCatch } from "../../../globalUtils/tryCatch.js"; import { apiHit } from "../../../globalUtils/apiHits.js"; import { siloConnectionType } from "../controller/siloAttachments/siloConnectionData.js"; import { detachSilo } from "../controller/siloAttachments/detachSilo.js"; const app = new OpenAPIHono(); // const Body = z // .object({ // age: z.number().optional().openapi({ example: 90 }), // //email: z.string().optional().openapi({example: "s.smith@example.com"}), // type: z.string().optional().openapi({ example: "fg" }), // }) // .openapi("User"); app.openapi( createRoute({ tags: ["logistics"], summary: "Returns all the silo connection based on connection type", method: "post", path: "/detachsilo", // request: { // body: { // content: { // "application/json": { schema: Body }, // }, // }, // }, // description: // "Provided a running number and lot number you can consume material.", responses: responses(), }), async (c: any) => { apiHit(c, { endpoint: "/attachSilo" }); const { data: body, error: bodyError } = await tryCatch(c.req.json()); if (bodyError) { return { success: false, message: "Missing mandatory data", data: [{ error: "Missing Data" }], }; } let b = body as any; const { data: silo, error } = await tryCatch(detachSilo(b)); if (error) { return c.json({ success: false, message: "Error detaching silo.", data: error, }); } console.log(silo); return c.json({ success: silo.success, message: silo.message, data: silo.data, }); } ); export default app;