Compare commits

...

7 Commits

7 changed files with 139 additions and 112 deletions

View File

@@ -1,17 +1,17 @@
{ {
"types": [ "types": [
{ "type": "feat", "section": "🌟 Enhancements" }, { "type": "feat", "section": "🌟 Enhancements" },
{ "type": "fix", "section": "🐛 Bug fixes" }, { "type": "fix", "section": "🐛 Bug fixes" },
{ "type": "chore", "hidden": false, "section": "📝 Chore" }, { "type": "chore", "hidden": false, "section": "📝 Chore" },
{ "type": "docs", "section": "📚 Documentation" }, { "type": "docs", "section": "📚 Documentation" },
{ "type": "style", "hidden": true }, { "type": "style", "hidden": true },
{ "type": "refactor", "section": "🛠️ Code Refactor" }, { "type": "refactor", "section": "🛠️ Code Refactor" },
{ "type": "perf", "hidden": false, "section": "🚀 Performance" }, { "type": "perf", "hidden": false, "section": "🚀 Performance" },
{ "type": "test", "section": "📝 Testing Code" }, { "type": "test", "section": "📝 Testing Code" },
{ "type": "ci", "hidden": false, "section": "📈 Project changes" }, { "type": "ci", "hidden": true, "section": "📈 Project changes" },
{ "type": "build", "hidden": true, "section": "📈 Project Builds" } { "type": "build", "hidden": true, "section": "📈 Project Builds" }
], ],
"commitUrlFormat": "https://git.tuffraid.net/cowch/lstV2/commits/{{hash}}", "commitUrlFormat": "https://git.tuffraid.net/cowch/lstV2/commits/{{hash}}",
"compareUrlFormat": "https://git.tuffraid.net/cowch/lstV2/compare/{{previousTag}}...{{currentTag}}", "compareUrlFormat": "https://git.tuffraid.net/cowch/lstV2/compare/{{previousTag}}...{{currentTag}}",
"header": "# All CHanges to LST can be found below.\n" "header": "# All CHanges to LST can be found below.\n"
} }

View File

@@ -35,7 +35,7 @@
} }
}, },
"admConfig": { "admConfig": {
"build": 148, "build": 152,
"oldBuild": "backend-0.1.3.zip" "oldBuild": "backend-0.1.3.zip"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -103,7 +103,7 @@ const updateBuildNumber = (appLock: string) => {
// Auto-commit changes // Auto-commit changes
execSync("git add package.json"); execSync("git add package.json");
execSync( execSync(
`git commit -m "chore(release): bump build number to ${pkgJson.admConfig.build}"` `git commit -m "ci(release): bump build number to ${pkgJson.admConfig.build}"`
); );
} else { } else {
createLog( createLog(

View File

@@ -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 type { User } from "../../../types/users.js";
import { alplaStockInv } from "./cycleCount/alplaStockInventory.js"; import { alplaStockInv } from "./cycleCount/alplaStockInventory.js";
import { emptyCount } from "./cycleCount/emptyCycleCount.js"; import { emptyCount } from "./cycleCount/emptyCycleCount.js";

View File

@@ -6,7 +6,6 @@ import { query } from "../../sqlServer/prodSqlServer.js";
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js"; import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
export const postLabelData = async (data: any) => { export const postLabelData = async (data: any) => {
console.log(data);
let newData = data; let newData = data;
if (Array.isArray(data)) { if (Array.isArray(data)) {
newData = { newData = {

View File

@@ -6,101 +6,107 @@ import { apiHit } from "../../../globalUtils/apiHits.js";
const app = new OpenAPIHono(); 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 areaFrom: z
.string() .string()
.optional() .optional()
.openapi({ example: "The server we are going to connect to" }), .openapi({ example: "The server we are going to connect to" }),
completed: z.boolean().optional().openapi({ example: true }), completed: z.boolean().optional().openapi({ example: true }),
}); });
app.openapi( app.openapi(
createRoute({ createRoute({
tags: ["ocme"], tags: ["ocme"],
summary: "Post New running number to be picked up.", summary: "Post New running number to be picked up.",
method: "post", method: "post",
path: "/postRunningNumber", path: "/postRunningNumber",
request: { request: {
body: { body: {
content: { content: {
"application/json": { schema: PostRunningNr }, "application/json": { schema: PostRunningNr },
},
},
}, },
}, responses: {
}, 200: {
responses: { content: {
200: { "application/json": {
content: { schema: z.object({
"application/json": { success: z.boolean().openapi({ example: true }),
schema: z.object({ message: z.string().openapi({ example: "Starter" }),
success: z.boolean().openapi({ example: true }), // data: z
message: z.string().openapi({ example: "Starter" }), // .array(z.object({sscc: z.string().optional()}))
// data: z // .optional()
// .array(z.object({sscc: z.string().optional()})) // .openapi({example: []}),
// .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", }),
}, async (c) => {
400: { // make sure we have a vaid user being accessed thats really logged in
content: { try {
"application/json": { const data = await c.req.json();
schema: z.object({ apiHit(c, {
success: z.boolean().openapi({ example: false }), endpoint: "api/ocme/postRunningNumber",
message: z lastBody: data,
.string() });
.optional() const postPallet: any = await postLabelData(data);
.openapi({ example: "Internal Server error" }), return c.json(
data: z.array(z.object({})).optional().openapi({ example: [] }), {
}), success: postPallet.success,
}, message: postPallet.message,
}, data: postPallet.data ?? [],
description: "Internal Server Error", },
}, 200
// 401: { );
// content: { } catch (error) {
// "application/json": { return c.json(
// schema: z.object({message: z.string().optional().openapi({example: "Unauthenticated"})}), {
// }, success: false,
// }, message: "There was an error getting ocmeInfo data",
// description: "Unauthorized", data: error,
// }, },
// 500: { 400
// 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
);
} }
}
); );
export default app; export default app;

View File

@@ -9,6 +9,7 @@ import { db } from "../../../database/dbclient.js";
import { settings } from "../../../database/schema/settings.js"; import { settings } from "../../../database/schema/settings.js";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import { postLabelData } from "../ocme/controller/postRunningNr.js"; import { postLabelData } from "../ocme/controller/postRunningNr.js";
import { tryCatch } from "../../globalUtils/tryCatch.js";
let tcpServer: net.Server; let tcpServer: net.Server;
let tcpSockets: Set<net.Socket> = new Set(); let tcpSockets: Set<net.Socket> = new Set();
@@ -27,8 +28,23 @@ export const startTCPServer = () => {
if (isServerRunning) if (isServerRunning)
return { success: false, message: "Server is already running" }; return { success: false, message: "Server is already running" };
tcpServer = net.createServer((socket) => { tcpServer = net.createServer(async (socket) => {
createLog("info", "tcp", "tcp", "Client connected"); createLog("debug", "tcp", "tcp", "Client connected");
const { data: setting, error: settingError } = await tryCatch(
db.select().from(settings)
);
if (settingError) {
return {
success: false,
message: "Error getting settings",
data: [],
};
}
const settingCheck = setting.filter(
(newData) => newData.name === "ocmeService"
);
tcpSockets.add(socket); tcpSockets.add(socket);
socket.on("data", (data: Buffer) => { socket.on("data", (data: Buffer) => {
@@ -50,11 +66,14 @@ export const startTCPServer = () => {
} }
// from the wrapper send the data // from the wrapper send the data
postLabelData(parseData); const ocmeSetting: any = settingCheck;
if (ocmeSetting[0]?.value === "1") {
postLabelData(parseData);
}
}); });
socket.on("end", () => { socket.on("end", () => {
createLog("info", "tcp", "tcp", "Client disconnected"); createLog("debug", "tcp", "tcp", "Client disconnected");
tcpSockets.delete(socket); tcpSockets.delete(socket);
}); });