35 lines
966 B
TypeScript
35 lines
966 B
TypeScript
// an external way to creating logs
|
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
|
import { getRequest } from "../controller/getRequests.js";
|
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
|
|
|
const app = new OpenAPIHono({ strict: false });
|
|
|
|
app.openapi(
|
|
createRoute({
|
|
tags: ["quality"],
|
|
summary: "Returns all pallets requested",
|
|
method: "get",
|
|
path: "/getrequest",
|
|
responses: responses(),
|
|
}),
|
|
async (c) => {
|
|
const { data, error } = await tryCatch(getRequest());
|
|
|
|
if (error) {
|
|
return c.json({
|
|
success: false,
|
|
message: "There was an error getting the printers",
|
|
});
|
|
}
|
|
|
|
return c.json({
|
|
success: data.success,
|
|
message: data.message,
|
|
data: data.data,
|
|
});
|
|
}
|
|
);
|
|
export default app;
|