refactor(command log): added in the command log tracking into the 3 we currently have
This commit is contained in:
@@ -5,6 +5,9 @@ import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { commandLog } from "../../../../../database/schema/commandLog.js";
|
||||
|
||||
type Data = {
|
||||
runningNr: string;
|
||||
@@ -34,7 +37,7 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
if (barcode.length === 0) {
|
||||
return {
|
||||
success: false,
|
||||
message: "The running number you've is not in stock.",
|
||||
message: "The running number you've entered not on stock.",
|
||||
};
|
||||
//throw Error("The provided runningNr is not in stock");
|
||||
}
|
||||
@@ -56,6 +59,12 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
},
|
||||
});
|
||||
//console.log(results);
|
||||
const { data: commandL, error: ce } = await tryCatch(
|
||||
db.insert(commandLog).values({
|
||||
commandUsed: "consumeMaterial",
|
||||
bodySent: data,
|
||||
})
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: "Material was consumed",
|
||||
|
||||
Reference in New Issue
Block a user