feat(lstv2 move): moved lstv2 into this app to keep them combined and easier to maintain
This commit is contained in:
53
lstV2/server/services/ocp/routes/labeling/manualPrint.ts
Normal file
53
lstV2/server/services/ocp/routes/labeling/manualPrint.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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 { labelingProcess } from "../../controller/labeling/labelProcess.js";
|
||||
import { apiHit } from "../../../../globalUtils/apiHits.js";
|
||||
import { manualLabelCreated } from "../../controller/labeling/labelRatio.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocp"],
|
||||
summary: "Manual print a label by line and printer name",
|
||||
method: "post",
|
||||
path: "/manualprintandfollow",
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
//const hours = c.req.query("hours");
|
||||
const { data: bodyData, error: bodyError } = await tryCatch(
|
||||
c.req.json()
|
||||
);
|
||||
apiHit(c, { endpoint: "/manualprintandfollow", lastBody: bodyData });
|
||||
|
||||
if (bodyError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "You are missing data",
|
||||
});
|
||||
}
|
||||
|
||||
const { data: createLabel, error: labelError } = await tryCatch(
|
||||
labelingProcess({ line: bodyData.line })
|
||||
);
|
||||
manualLabelCreated();
|
||||
if (labelError) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "There was an error creating the label.",
|
||||
data: labelError,
|
||||
});
|
||||
}
|
||||
|
||||
const newLabel: any = createLabel;
|
||||
return c.json({
|
||||
success: newLabel.success,
|
||||
message: newLabel.message,
|
||||
data: newLabel.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
Reference in New Issue
Block a user