Files
lstV2/server/services/ocp/routes/printers/updatePrinters.ts

51 lines
1.6 KiB
TypeScript

// an external way to creating logs
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { updatePrinters } from "../../controller/printers/updatePrinters.js";
const app = new OpenAPIHono({ strict: false });
const CreateLog = z.object({
line: z.string().openapi({ example: "info" }),
initials: z.string().openapi({ example: "server" }),
printReason: z.string().openapi({ example: "This is a new log posted" }),
additionalComments: z
.string()
.optional()
.openapi({ example: "Some reason why we did this." }),
});
app.openapi(
createRoute({
tags: ["ocp"],
summary: "Prints a label.",
method: "get",
path: "/updateprinters",
//middleware: authMiddleware,
//description: "This might be a temp soltuin during the transtion between versions",
request: {
body: { content: { "application/json": { schema: CreateLog } } },
},
responses: responses(),
}),
async (c) => {
const { data: printData, error: printError } = await tryCatch(
updatePrinters()
);
if (printError) {
return c.json({
success: false,
message: "There was an error getting the printers",
});
}
return c.json({
success: printData.success,
message: printData.message,
data: printData.data,
});
}
);
export default app;