style(ocme): format changes
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { db } from "../../../../database/dbclient.js";
|
||||
import { settings } from "../../../../database/schema/settings.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import type { User } from "../../../types/users.js";
|
||||
import { alplaStockInv } from "./cycleCount/alplaStockInventory.js";
|
||||
import { emptyCount } from "./cycleCount/emptyCycleCount.js";
|
||||
|
||||
@@ -6,7 +6,6 @@ import { query } from "../../sqlServer/prodSqlServer.js";
|
||||
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
||||
|
||||
export const postLabelData = async (data: any) => {
|
||||
console.log(data);
|
||||
let newData = data;
|
||||
if (Array.isArray(data)) {
|
||||
newData = {
|
||||
|
||||
@@ -6,101 +6,107 @@ import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const PostRunningNr = z.object({
|
||||
sscc: z.string().optional().openapi({ example: "00090103830005710997" }),
|
||||
runningNr: z.string().optional().openapi({ example: "localhost" }),
|
||||
areaFrom: z
|
||||
.string()
|
||||
.optional()
|
||||
.openapi({ example: "The server we are going to connect to" }),
|
||||
completed: z.boolean().optional().openapi({ example: true }),
|
||||
sscc: z.string().optional().openapi({ example: "00090103830005710997" }),
|
||||
runningNr: z.string().optional().openapi({ example: "localhost" }),
|
||||
areaFrom: z
|
||||
.string()
|
||||
.optional()
|
||||
.openapi({ example: "The server we are going to connect to" }),
|
||||
completed: z.boolean().optional().openapi({ example: true }),
|
||||
});
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["ocme"],
|
||||
summary: "Post New running number to be picked up.",
|
||||
method: "post",
|
||||
path: "/postRunningNumber",
|
||||
request: {
|
||||
body: {
|
||||
content: {
|
||||
"application/json": { schema: PostRunningNr },
|
||||
createRoute({
|
||||
tags: ["ocme"],
|
||||
summary: "Post New running number to be picked up.",
|
||||
method: "post",
|
||||
path: "/postRunningNumber",
|
||||
request: {
|
||||
body: {
|
||||
content: {
|
||||
"application/json": { schema: PostRunningNr },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
success: z.boolean().openapi({ example: true }),
|
||||
message: z.string().openapi({ example: "Starter" }),
|
||||
// data: z
|
||||
// .array(z.object({sscc: z.string().optional()}))
|
||||
// .optional()
|
||||
// .openapi({example: []}),
|
||||
}),
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
success: z.boolean().openapi({ example: true }),
|
||||
message: z.string().openapi({ example: "Starter" }),
|
||||
// data: z
|
||||
// .array(z.object({sscc: z.string().optional()}))
|
||||
// .optional()
|
||||
// .openapi({example: []}),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Response message",
|
||||
},
|
||||
400: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
success: z.boolean().openapi({ example: false }),
|
||||
message: z
|
||||
.string()
|
||||
.optional()
|
||||
.openapi({ example: "Internal Server error" }),
|
||||
data: z
|
||||
.array(z.object({}))
|
||||
.optional()
|
||||
.openapi({ example: [] }),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Internal Server Error",
|
||||
},
|
||||
// 401: {
|
||||
// content: {
|
||||
// "application/json": {
|
||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
||||
// },
|
||||
// },
|
||||
// description: "Unauthorized",
|
||||
// },
|
||||
// 500: {
|
||||
// content: {
|
||||
// "application/json": {
|
||||
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
||||
// },
|
||||
// },
|
||||
// description: "Internal Server Error",
|
||||
// },
|
||||
},
|
||||
description: "Response message",
|
||||
},
|
||||
400: {
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
success: z.boolean().openapi({ example: false }),
|
||||
message: z
|
||||
.string()
|
||||
.optional()
|
||||
.openapi({ example: "Internal Server error" }),
|
||||
data: z.array(z.object({})).optional().openapi({ example: [] }),
|
||||
}),
|
||||
},
|
||||
},
|
||||
description: "Internal Server Error",
|
||||
},
|
||||
// 401: {
|
||||
// content: {
|
||||
// "application/json": {
|
||||
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}),
|
||||
// },
|
||||
// },
|
||||
// description: "Unauthorized",
|
||||
// },
|
||||
// 500: {
|
||||
// content: {
|
||||
// "application/json": {
|
||||
// schema: z.object({message: z.string().optional().openapi({example: "Internal Server error"})}),
|
||||
// },
|
||||
// },
|
||||
// description: "Internal Server Error",
|
||||
// },
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
// make sure we have a vaid user being accessed thats really logged in
|
||||
try {
|
||||
const data = await c.req.json();
|
||||
apiHit(c, { endpoint: "api/ocme/postRunningNumber", lastBody: data });
|
||||
const postPallet = await postLabelData(data);
|
||||
return c.json(
|
||||
{
|
||||
success: postPallet.success,
|
||||
message: postPallet.message,
|
||||
data: postPallet.data ?? [],
|
||||
},
|
||||
200
|
||||
);
|
||||
} catch (error) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
message: "There was an error getting ocmeInfo data",
|
||||
data: error,
|
||||
},
|
||||
400
|
||||
);
|
||||
}),
|
||||
async (c) => {
|
||||
// make sure we have a vaid user being accessed thats really logged in
|
||||
try {
|
||||
const data = await c.req.json();
|
||||
apiHit(c, {
|
||||
endpoint: "api/ocme/postRunningNumber",
|
||||
lastBody: data,
|
||||
});
|
||||
const postPallet: any = await postLabelData(data);
|
||||
return c.json(
|
||||
{
|
||||
success: postPallet.success,
|
||||
message: postPallet.message,
|
||||
data: postPallet.data ?? [],
|
||||
},
|
||||
200
|
||||
);
|
||||
} catch (error) {
|
||||
return c.json(
|
||||
{
|
||||
success: false,
|
||||
message: "There was an error getting ocmeInfo data",
|
||||
data: error,
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user