refactor(ocme): cleaup on pickedup
This commit is contained in:
@@ -8,7 +8,10 @@ const app = new OpenAPIHono();
|
|||||||
const PostRunningNr = z.object({
|
const PostRunningNr = z.object({
|
||||||
sscc: z.string().optional().openapi({ example: "00090103830005710997" }),
|
sscc: z.string().optional().openapi({ example: "00090103830005710997" }),
|
||||||
runningNr: z.string().optional().openapi({ example: "localhost" }),
|
runningNr: z.string().optional().openapi({ example: "localhost" }),
|
||||||
areaFrom: z.string().optional().openapi({example: "The server we are going to connect to"}),
|
areaFrom: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "The server we are going to connect to" }),
|
||||||
completed: z.boolean().optional().openapi({ example: true }),
|
completed: z.boolean().optional().openapi({ example: true }),
|
||||||
all: z.boolean().optional().openapi({ example: false }),
|
all: z.boolean().optional().openapi({ example: false }),
|
||||||
});
|
});
|
||||||
@@ -20,7 +23,7 @@ app.openapi(
|
|||||||
method: "patch",
|
method: "patch",
|
||||||
description:
|
description:
|
||||||
"removes the pallet(s) from showing as needed to be picked up, we clear everything related to the pallet number to reduce the risk of a mix, passing `all` will just clear everything that is pending.",
|
"removes the pallet(s) from showing as needed to be picked up, we clear everything related to the pallet number to reduce the risk of a mix, passing `all` will just clear everything that is pending.",
|
||||||
path: "/pickedup",
|
path: "/pickedUp",
|
||||||
request: {
|
request: {
|
||||||
body: {
|
body: {
|
||||||
content: {
|
content: {
|
||||||
@@ -49,7 +52,10 @@ app.openapi(
|
|||||||
"application/json": {
|
"application/json": {
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
success: z.boolean().openapi({ example: false }),
|
success: z.boolean().openapi({ example: false }),
|
||||||
message: z.string().optional().openapi({example: "Internal Server error"}),
|
message: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Internal Server error" }),
|
||||||
data: z.array(z.object({})).optional().openapi({ example: [] }),
|
data: z.array(z.object({})).optional().openapi({ example: [] }),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@@ -67,7 +73,12 @@ app.openapi(
|
|||||||
500: {
|
500: {
|
||||||
content: {
|
content: {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
schema: z.object({
|
||||||
|
message: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Internal Server error" }),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: "Internal Server Error",
|
description: "Internal Server Error",
|
||||||
@@ -80,9 +91,23 @@ app.openapi(
|
|||||||
const data = await c.req.json();
|
const data = await c.req.json();
|
||||||
apiHit(c, { endpoint: "api/ocme/pickedup", lastBody: data });
|
apiHit(c, { endpoint: "api/ocme/pickedup", lastBody: data });
|
||||||
const postPallet = await pickedup(data);
|
const postPallet = await pickedup(data);
|
||||||
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data}, 200);
|
return c.json(
|
||||||
|
{
|
||||||
|
success: postPallet.success,
|
||||||
|
message: postPallet.message,
|
||||||
|
data: postPallet.data,
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400);
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error getting ocmeInfo data",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user