Files
lst/lstV2/server/services/quality/route/getRequest.ts

36 lines
1.0 KiB
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";
import { apiHit } from "../../../globalUtils/apiHits.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());
apiHit(c, { endpoint: "/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;