feat(lstv2 move): moved lstv2 into this app to keep them combined and easier to maintain
This commit is contained in:
40
lstV2/server/services/ocp/routes/labeling/getLabels.ts
Normal file
40
lstV2/server/services/ocp/routes/labeling/getLabels.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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 { getLabels } from "../../controller/labeling/getLabels.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp"],
|
||||
summary: "Returns current active lots that are tech released",
|
||||
method: "get",
|
||||
path: "/getlabels",
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
const hours = c.req.query("hours");
|
||||
const { data: labelData, error: labelError } = await tryCatch(
|
||||
getLabels(hours ?? "2")
|
||||
);
|
||||
apiHit(c, { endpoint: "/getLabels" });
|
||||
|
||||
if (labelError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "There was an error getting the printers",
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: labelData.success,
|
||||
message: labelData.message,
|
||||
count: labelData.count,
|
||||
data: labelData.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
Reference in New Issue
Block a user