feat(cyclecountcheck): added i cycle count check this is in mem right now
if this becomes a resource hog we will move it to the db. no need for it to really be presitant
This commit is contained in:
60
server/services/logistics/route/getCycleCountChecks.ts
Normal file
60
server/services/logistics/route/getCycleCountChecks.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { getCycleCountCheck } from "../controller/warehouse/cycleCountChecks/getCycleCountCheck.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const Body = z
|
||||
.object({
|
||||
age: z.number().optional().openapi({ example: 90 }),
|
||||
//email: z.string().optional().openapi({example: "s.smith@example.com"}),
|
||||
type: z.string().optional().openapi({ example: "fg" }),
|
||||
})
|
||||
.openapi("User");
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["logistics"],
|
||||
summary: "Returns lanes that need cycle counted",
|
||||
method: "post",
|
||||
path: "/cyclecountcheck",
|
||||
request: {
|
||||
body: {
|
||||
content: {
|
||||
"application/json": { schema: Body },
|
||||
},
|
||||
},
|
||||
},
|
||||
// description:
|
||||
// "Provided a running number and lot number you can consume material.",
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c: any) => {
|
||||
//apiHit(c, { endpoint: "api/sqlProd/close" });
|
||||
const { data: body, error: be } = await tryCatch(c.req.json());
|
||||
|
||||
if (be) {
|
||||
return c.json({ success: false, message: "Missing Data." });
|
||||
}
|
||||
|
||||
const check: any = body;
|
||||
const { data: lanes, error: le } = await tryCatch(
|
||||
getCycleCountCheck(check.age, check.type)
|
||||
);
|
||||
|
||||
if (le) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "Error getting lane data.",
|
||||
data: le,
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: lanes.success,
|
||||
message: lanes.message,
|
||||
data: lanes.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
Reference in New Issue
Block a user