fix(ocme): fixed some import errors
This commit is contained in:
@@ -4,12 +4,6 @@ import { createSSCC } from "../../../globalUtils/createSSCC.js";
|
|||||||
import { createLog } from "../../logger/logger.js";
|
import { createLog } from "../../logger/logger.js";
|
||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
||||||
import { db } from "../../../../database/dbclient.js";
|
|
||||||
import { ocmeData } from "../../../../database/schema/ocme.js";
|
|
||||||
import { createSSCC } from "../../../globalUtils/createSSCC.js";
|
|
||||||
import { createLog } from "../../logger/logger.js";
|
|
||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
|
||||||
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
|
||||||
|
|
||||||
export const postLabelData = async (data: any) => {
|
export const postLabelData = async (data: any) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|||||||
@@ -1,20 +1,44 @@
|
|||||||
import {db} from "../../../../database/dbclient.js";
|
import { db } from "../../../../database/dbclient.js";
|
||||||
import {manualPrinting} from "../../../../database/schema/ocpManualPrint.js";
|
import { manualPrinting } from "../../../../database/schema/ocpManualPrint.js";
|
||||||
|
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||||
|
|
||||||
export const manualPrint = async (data: any) => {
|
export const manualPrint = async (manualPrint: any) => {
|
||||||
/**
|
/**
|
||||||
* add the reason we did a manual print.
|
* add the reason we did a manual print.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const manualPrintData = {
|
const manualPrintData = {
|
||||||
line: data.line,
|
line: manualPrint.line,
|
||||||
printReason: data.printReason,
|
printReason: manualPrint.printReason,
|
||||||
initials: data.initials,
|
initials: manualPrint.initials,
|
||||||
additionalComments: data?.additionalComments,
|
additionalComments: manualPrint?.additionalComments,
|
||||||
add_user: "lst",
|
add_user: "lst",
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
const { data, error } = await tryCatch(
|
||||||
const manualPrint = await db.insert(manualPrinting).values(manualPrintData);
|
db
|
||||||
} catch (error) {}
|
.insert(manualPrinting)
|
||||||
|
.values(manualPrintData)
|
||||||
|
.returning({
|
||||||
|
line: manualPrinting.line,
|
||||||
|
printReason: manualPrinting.printReason,
|
||||||
|
initials: manualPrinting.initials,
|
||||||
|
additionalComments: manualPrinting?.additionalComments,
|
||||||
|
add_user: manualPrinting.add_user,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "There was an error posting the manualPrintData",
|
||||||
|
data: error,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "There was an error posting the manualPrintData",
|
||||||
|
data,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
// an external way to creating logs
|
// an external way to creating logs
|
||||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
||||||
import {responses} from "../../../globalUtils/routeDefs/responses.js";
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||||
import type {User} from "../../../types/users.js";
|
import type { User } from "../../../types/users.js";
|
||||||
import {verify} from "hono/jwt";
|
import { verify } from "hono/jwt";
|
||||||
import {manualPrint} from "../controller/manualLabelLog.js";
|
import { manualPrint } from "../controller/manualLabelLog.js";
|
||||||
import {authMiddleware} from "../../auth/middleware/authMiddleware.js";
|
import { authMiddleware } from "../../auth/middleware/authMiddleware.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono({strict: false});
|
const app = new OpenAPIHono({ strict: false });
|
||||||
const CreateLog = z.object({
|
const CreateLog = z.object({
|
||||||
line: z.string().openapi({example: "info"}),
|
line: z.string().openapi({ example: "info" }),
|
||||||
initials: z.string().openapi({example: "server"}),
|
initials: z.string().openapi({ example: "server" }),
|
||||||
printReason: z.string().openapi({example: "This is a new log posted"}),
|
printReason: z.string().openapi({ example: "This is a new log posted" }),
|
||||||
additionalComments: z.string().optional().openapi({example: "Some reason why we did this."}),
|
additionalComments: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.openapi({ example: "Some reason why we did this." }),
|
||||||
});
|
});
|
||||||
|
|
||||||
app.openapi(
|
app.openapi(
|
||||||
@@ -24,32 +27,33 @@ app.openapi(
|
|||||||
//middleware: authMiddleware,
|
//middleware: authMiddleware,
|
||||||
//description: "This might be a temp soltuin during the transtion between versions",
|
//description: "This might be a temp soltuin during the transtion between versions",
|
||||||
request: {
|
request: {
|
||||||
body: {content: {"application/json": {schema: CreateLog}}},
|
body: { content: { "application/json": { schema: CreateLog } } },
|
||||||
},
|
},
|
||||||
responses: responses(),
|
responses: responses(),
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const body = await c.req.json();
|
const body = await c.req.json();
|
||||||
apiHit(c, {endpoint: `api/logger/logs/id`});
|
apiHit(c, { endpoint: `api/logger/logs/id` });
|
||||||
// const authHeader = c.req.header("Authorization");
|
|
||||||
|
|
||||||
// const token = authHeader?.split("Bearer ")[1] || "";
|
|
||||||
// let user: User;
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// const payload = await verify(token, process.env.JWT_SECRET!);
|
|
||||||
// user = payload.user as User;
|
|
||||||
// } catch (error) {
|
|
||||||
// console.log(error);
|
|
||||||
// return c.json({message: "Unauthorized"}, 401);
|
|
||||||
// }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//const data = {...body, add_user: user.username};
|
//const data = {...body, add_user: user.username};
|
||||||
await manualPrint(body);
|
const printLog: any = await manualPrint(body);
|
||||||
return c.json({success: true, message: "Manual Print was added.", data: []}, 200);
|
return c.json(
|
||||||
|
{
|
||||||
|
success: printLog.success,
|
||||||
|
message: printLog.message,
|
||||||
|
data: printLog.data ?? [],
|
||||||
|
},
|
||||||
|
200
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return c.json({success: false, message: "There was an error clearing the log.", data: error}, 400);
|
return c.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "There was an error clearing the log.",
|
||||||
|
data: error,
|
||||||
|
},
|
||||||
|
400
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user