test(ocme): lots of changes to get it working in production

This commit is contained in:
2025-03-24 15:31:31 -05:00
parent 0c5fc1dfb0
commit 6dd9ed848b
14 changed files with 957 additions and 779 deletions

View File

@@ -1,185 +1,212 @@
import {toast} from "sonner"; import { toast } from "sonner";
import {LstCard} from "../extendedUI/LstCard"; import { LstCard } from "../extendedUI/LstCard";
import {Button} from "../ui/button"; import { Button } from "../ui/button";
import {Input} from "../ui/input"; import { Input } from "../ui/input";
import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "../ui/table"; import {
import {Skeleton} from "../ui/skeleton"; Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "../ui/table";
import { Skeleton } from "../ui/skeleton";
//import CycleCountLog from "./CycleCountLog"; //import CycleCountLog from "./CycleCountLog";
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "../ui/select"; import {
import {Controller, useForm} from "react-hook-form"; Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "../ui/select";
import { Controller, useForm } from "react-hook-form";
import axios from "axios"; import axios from "axios";
import {useState} from "react"; import { useState } from "react";
export default function OcmeCycleCount() { export default function OcmeCycleCount() {
const token = localStorage.getItem("auth_token"); const token = localStorage.getItem("auth_token");
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [counting, setCounting] = useState(false); const [counting, setCounting] = useState(false);
const { const {
register, register,
handleSubmit, handleSubmit,
//watch, //watch,
formState: {errors}, formState: { errors },
reset, reset,
control, control,
} = useForm(); } = useForm();
const onSubmit = async (data: any) => { const onSubmit = async (data: any) => {
setData([]); setData([]);
setCounting(true); setCounting(true);
toast.success(`Cycle count started`); toast.success(`Cycle count started`);
try { try {
const res = await axios.post("/ocme/api/v1/cyclecount", data, { const res = await axios.post("/ocme/api/v1/cycleCount", data, {
headers: {Authorization: `Bearer ${token}`}, headers: { Authorization: `Bearer ${token}` },
}); });
toast.success(res.data.message); console.log(data);
setData(res.data.data); toast.success(res.data.message);
setCounting(false); setData(res.data.data);
reset(); setCounting(false);
} catch (error) { reset();
toast.error("There was an error cycle counting"); } catch (error) {
setCounting(false); toast.error("There was an error cycle counting");
reset(); setCounting(false);
} reset();
}; }
return ( };
<div className="flex flex-row w-screen">
<div className="m-2 w-5/6"> return (
<LstCard> <div className="flex flex-row w-screen">
<p className="ml-2">Please enter the name or laneID you want to cycle count.</p> <div className="m-2 w-5/6">
<div> <LstCard>
<form onSubmit={handleSubmit(onSubmit)}> <p className="ml-2">
<div className="flex justify-between"> Please enter the name or laneID you want to cycle count.
<div className="m-2 flex flex-row"> </p>
<Input <div>
placeholder="enter lane: L064" <form onSubmit={handleSubmit(onSubmit)}>
className={errors.lane ? "border-red-500" : ""} <div className="flex justify-between">
aria-invalid={!!errors.lane} <div className="m-2 flex flex-row">
{...register("lane", { <Input
required: true, placeholder="enter lane: L064"
minLength: { className={errors.lane ? "border-red-500" : ""}
value: 3, aria-invalid={!!errors.lane}
message: "The lane is too short!", {...register("lane", {
}, required: true,
})} minLength: {
/> value: 3,
<div className="ml-2"> message: "The lane is too short!",
<Controller },
control={control} })}
name="laneType" />
defaultValue={""} <div className="ml-2">
render={({ <Controller
field: {onChange}, control={control}
fieldState: {}, name="laneType"
//formState, defaultValue={""}
}) => ( render={({
<Select onValueChange={onChange}> field: { onChange },
<SelectTrigger className="w-[180px]"> fieldState: {},
<SelectValue placeholder="Select name or id" /> //formState,
</SelectTrigger> }) => (
<SelectContent> <Select onValueChange={onChange}>
<SelectItem value="name">Name</SelectItem> <SelectTrigger className="w-[180px]">
<SelectItem value="laneId">Lane ID</SelectItem> <SelectValue placeholder="Select name or id" />
</SelectContent> </SelectTrigger>
</Select> <SelectContent>
)} <SelectItem value="name">Name</SelectItem>
/> <SelectItem value="laneId">Lane ID</SelectItem>
</div> </SelectContent>
</div> </Select>
<Button className="m-2" type="submit" disabled={counting}> )}
{counting ? <span>Counting...</span> : <span>CycleCount</span>} />
</Button> </div>
</div> </div>
</form> <Button className="m-2" type="submit" disabled={counting}>
</div> {counting ? (
<div> <span>Counting...</span>
<Table> ) : (
<TableHeader> <span>CycleCount</span>
<TableRow> )}
<TableHead>LaneID</TableHead> </Button>
<TableHead>Lane</TableHead> </div>
<TableHead>AV</TableHead> </form>
<TableHead>Description</TableHead> </div>
<TableHead>Running Number</TableHead> <div>
<TableHead>In Ocme</TableHead> <Table>
<TableHead>In Stock</TableHead> <TableHeader>
<TableHead>Result</TableHead> <TableRow>
</TableRow> <TableHead>LaneID</TableHead>
</TableHeader> <TableHead>Lane</TableHead>
{data.length === 0 ? ( <TableHead>AV</TableHead>
<TableBody> <TableHead>Description</TableHead>
{Array(10) <TableHead>Running Number</TableHead>
.fill(0) <TableHead>In Ocme</TableHead>
.map((_, i) => ( <TableHead>In Stock</TableHead>
<TableRow key={i}> <TableHead>Result</TableHead>
<TableCell className="font-medium"> </TableRow>
<Skeleton className="h-4" /> </TableHeader>
</TableCell> {data?.length === 0 ? (
<TableCell> <TableBody>
<Skeleton className="h-4" /> {Array(10)
</TableCell> .fill(0)
<TableCell> .map((_, i) => (
<Skeleton className="h-4" /> <TableRow key={i}>
</TableCell> <TableCell className="font-medium">
<TableCell> <Skeleton className="h-4" />
<Skeleton className="h-4" /> </TableCell>
</TableCell> <TableCell>
<TableCell> <Skeleton className="h-4" />
<Skeleton className="h-4" /> </TableCell>
</TableCell> <TableCell>
<TableCell> <Skeleton className="h-4" />
<Skeleton className="h-4" /> </TableCell>
</TableCell> <TableCell>
<TableCell> <Skeleton className="h-4" />
<Skeleton className="h-4" /> </TableCell>
</TableCell> <TableCell>
<TableCell> <Skeleton className="h-4" />
<Skeleton className="h-4" /> </TableCell>
</TableCell> <TableCell>
</TableRow> <Skeleton className="h-4" />
))} </TableCell>
</TableBody> <TableCell>
) : ( <Skeleton className="h-4" />
<> </TableCell>
{data.map((i: any) => { <TableCell>
let classname = ``; <Skeleton className="h-4" />
if (i.info === "Quality Check Required") { </TableCell>
classname = `bg-red-500`; </TableRow>
} ))}
if (i.info === "Sent to Inv") { </TableBody>
classname = `bg-amber-700`; ) : (
} <>
return ( {data?.map((i: any) => {
<TableRow key={i.runningNumber}> let classname = ``;
<TableCell className={`font-medium ${classname}`}> if (i.info === "Quality Check Required") {
{i.alpla_laneID} classname = `bg-red-500`;
</TableCell> }
<TableCell className={`font-medium ${classname}`}> if (i.info === "Sent to Inv") {
{i.alpla_laneDescription} classname = `bg-amber-700`;
</TableCell> }
<TableCell className={`font-medium ${classname}`}> return (
{i.Article} <TableRow key={i.runningNumber}>
</TableCell> <TableCell className={`font-medium ${classname}`}>
<TableCell className={`font-medium ${classname}`}> {i.alpla_laneID}
{i.alpla_laneDescription} </TableCell>
</TableCell> <TableCell className={`font-medium ${classname}`}>
<TableCell className={`font-medium ${classname}`}> {i.alpla_laneDescription}
{i.runningNumber} </TableCell>
</TableCell> <TableCell className={`font-medium ${classname}`}>
<TableCell className={`font-medium ${classname}`}>{i.ocme}</TableCell> {i.Article}
<TableCell className={`font-medium ${classname}`}>{i.stock}</TableCell> </TableCell>
<TableCell className={`font-medium ${classname}`}>{i.info}</TableCell> <TableCell className={`font-medium ${classname}`}>
</TableRow> {i.alpla_laneDescription}
); </TableCell>
})} <TableCell className={`font-medium ${classname}`}>
</> {i.runningNumber}
)} </TableCell>
</Table> <TableCell className={`font-medium ${classname}`}>
</div> {i.ocme}
</LstCard> </TableCell>
</div> <TableCell className={`font-medium ${classname}`}>
{/* <div className="m-2"> {i.stock}
</TableCell>
<TableCell className={`font-medium ${classname}`}>
{i.info}
</TableCell>
</TableRow>
);
})}
</>
)}
</Table>
</div>
</LstCard>
</div>
{/* <div className="m-2">
<CycleCountLog /> <CycleCountLog />
</div> */} </div> */}
</div> </div>
); );
} }

View File

@@ -32,7 +32,7 @@
} }
}, },
"admConfig": { "admConfig": {
"build": 53, "build": 54,
"oldBuild": "backend-0.1.3.zip" "oldBuild": "backend-0.1.3.zip"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -53,17 +53,17 @@ app.use(
); );
// Middleware to normalize route case // Middleware to normalize route case
app.use("*", async (c, next) => { // app.use("*", async (c, next) => {
const lowercasedUrl = c.req.url.toLowerCase(); // const lowercasedUrl = c.req.url.toLowerCase();
//console.log("Incoming Request:", c.req.url, c.req.method); // //console.log("Incoming Request:", c.req.url, c.req.method);
// If the URL is already lowercase, continue as usual // // If the URL is already lowercase, continue as usual
if (c.req.url === lowercasedUrl) { // if (c.req.url === lowercasedUrl) {
return next(); // await next();
} // }
// Otherwise, re-route internally // // Otherwise, re-route internally
return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method // return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method
}); // });
app.doc("/api/ref", { app.doc("/api/ref", {
openapi: "3.0.0", openapi: "3.0.0",

View File

@@ -415,10 +415,10 @@ try {
Start-Service -DisplayName $serviceLstV2 Start-Service -DisplayName $serviceLstV2
Start-Sleep -Seconds 1 Start-Sleep -Seconds 1
Write-Host "$($server) finished updating" Write-Host "$($server) finished updating"
if($token -eq "usday1"){ # if($token -eq "usday1"){
Write-Host "Starting $($serviceOcme)" # Write-Host "Starting $($serviceOcme)"
Start-Service -DisplayName $serviceOcme # Start-Service -DisplayName $serviceOcme
} # }
} }
Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $server, $token, $location, $buildZip, $buildLoc, $obslst, $obsBuild -Credential $credentials Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $server, $token, $location, $buildZip, $buildLoc, $obslst, $obsBuild -Credential $credentials

View File

@@ -1,173 +1,189 @@
import {spawn} from "child_process"; import { spawn } from "child_process";
import {getAppInfo} from "../globalUtils/appInfo.js"; import { getAppInfo } from "../globalUtils/appInfo.js";
import {db} from "../../database/dbclient.js"; import { db } from "../../database/dbclient.js";
import {serverData} from "../../database/schema/serverData.js"; import { serverData } from "../../database/schema/serverData.js";
import {eq, sql} from "drizzle-orm"; import { eq, sql } from "drizzle-orm";
import {createLog} from "../services/logger/logger.js"; import { createLog } from "../services/logger/logger.js";
type UpdateServerResponse = { type UpdateServerResponse = {
success: boolean; success: boolean;
message: string; message: string;
}; };
export const updateServer = async (devApp: string, server: string | null): Promise<UpdateServerResponse> => { export const updateServer = async (
const app = await getAppInfo(devApp); devApp: string,
const serverInfo = await db server: string | null
): Promise<UpdateServerResponse> => {
const app = await getAppInfo(devApp);
const serverInfo = await db
.select() .select()
.from(serverData) .from(serverData)
.where(eq(serverData.plantToken, server?.toLowerCase() ?? "")); .where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
if (serverInfo.length === 0) { if (serverInfo.length === 0) {
createLog( createLog(
"error", "error",
"lst", "lst",
"serverUpdater", "serverUpdater",
`Looks like you are missing the plant token or have entered an incorrect one please try again.` `Looks like you are missing the plant token or have entered an incorrect one please try again.`
); );
return { return {
success: false, success: false,
message: "Looks like you are missing the plant token or have entered an incorrect one please try again.", message:
}; "Looks like you are missing the plant token or have entered an incorrect one please try again.",
} };
}
if (serverInfo[0].isUpgrading) { if (serverInfo[0].isUpgrading) {
createLog( createLog(
"error", "error",
"lst", "lst",
"serverUpdater", "serverUpdater",
`Looks like ${serverInfo[0].plantToken} is upgrading already you cant do this again.` `Looks like ${serverInfo[0].plantToken} is upgrading already you cant do this again.`
); );
return { return {
success: false, success: false,
message: `Looks like ${serverInfo[0].plantToken} is upgrading already you cant do this again.`, message: `Looks like ${serverInfo[0].plantToken} is upgrading already you cant do this again.`,
}; };
} }
const scriptPath = `${process.env.DEVFOLDER}\\server\\scripts\\update.ps1 `; const scriptPath = `${process.env.DEVFOLDER}\\server\\scripts\\update.ps1 `;
const args = [ const args = [
"-NoProfile", "-NoProfile",
"-ExecutionPolicy", "-ExecutionPolicy",
"Bypass", "Bypass",
"-File", "-File",
scriptPath, scriptPath,
"-username", "-username",
process.env.ADMUSER, // needs moved to somewhere else. process.env.ADMUSER, // needs moved to somewhere else.
"-admpass", "-admpass",
process.env.ADMPASSWORD, // needs moved to somewhere else. process.env.ADMPASSWORD, // needs moved to somewhere else.
"-devFolder", "-devFolder",
process.env.DEVFOLDER, process.env.DEVFOLDER,
"-server", "-server",
serverInfo[0].serverDNS, serverInfo[0].serverDNS,
"-serverIP", "-serverIP",
serverInfo[0].idAddress, serverInfo[0].idAddress,
"-token", "-token",
serverInfo[0].plantToken, serverInfo[0].plantToken,
"-build", "-build",
`${process.env.DEVFOLDER}\\builds`, `${process.env.DEVFOLDER}\\builds`,
"-location", "-location",
serverInfo[0].serverLoc, serverInfo[0].serverLoc,
"-obslst", "-obslst",
serverInfo[0].oldVersion, serverInfo[0].oldVersion,
"-obsBuild", "-obsBuild",
app.admConfig.oldBuild, app.admConfig.oldBuild,
, ,
]; ];
return new Promise(async (resolve, reject) => { console.log(args);
const process = spawn("powershell", args);
// change the server to upgradeing
await db
.update(serverData)
.set({isUpgrading: true})
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
//let stdout = "";
//let stderr = "";
// Collect stdout data return new Promise(async (resolve, reject) => {
process.stdout.on("data", (data) => { const process = spawn("powershell", args);
const output = data.toString().trim(); // change the server to upgradeing
createLog("info", "lst", "serverUpdater", `${output}`); await db
//onData(output); .update(serverData)
}); .set({ isUpgrading: true })
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
//let stdout = "";
//let stderr = "";
// Collect stderr data // Collect stdout data
process.stderr.on("data", (data) => { process.stdout.on("data", (data) => {
const output = data.toString().trim(); const output = data.toString().trim();
createLog("info", "lst", "serverUpdater", `${output}`); createLog("info", "lst", "serverUpdater", `${output}`);
//onData(output); //onData(output);
});
// Handle process close
process.on("close", async (code) => {
if (code === 0) {
// if (count >= servers) {
// //onClose(`Server completed with code: ${code}`);
// }
createLog("info", "lst", "serverUpdater", `${server}`);
//update the last build.
try {
await db
.update(serverData)
.set({lastUpdated: sql`NOW()`, isUpgrading: false})
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
createLog(
"info",
"lst",
"serverUpdater",
`${server?.toLowerCase()}, has been updated and can now be used again.`
);
} catch (error) {
createLog(
"error",
"lst",
"serverUpdater",
`There was an error updating the last time the server was updated: ${error}`
);
}
resolve({
success: true,
message: `${server?.toLowerCase()}, has been updated and can now be used again.`,
});
} else {
const errorMessage = `Process exited with code ${code}`;
// if (count >= servers) {
// //onClose(code);
// }
reject({
success: false,
message: `${server?.toLowerCase()}, Has encounted an error while updating.`,
});
}
});
// Handle errors with the process itself
process.on("error", (error) => {
//onError(err.message);
createLog("error", "lst", "serverUpdater", `${error}`);
reject(error);
});
}); });
// Collect stderr data
process.stderr.on("data", (data) => {
const output = data.toString().trim();
createLog("info", "lst", "serverUpdater", `${output}`);
//onData(output);
});
// Handle process close
process.on("close", async (code) => {
if (code === 0) {
// if (count >= servers) {
// //onClose(`Server completed with code: ${code}`);
// }
createLog("info", "lst", "serverUpdater", `${server}`);
//update the last build.
try {
await db
.update(serverData)
.set({ lastUpdated: sql`NOW()`, isUpgrading: false })
.where(eq(serverData.plantToken, server?.toLowerCase() ?? ""));
createLog(
"info",
"lst",
"serverUpdater",
`${server?.toLowerCase()}, has been updated and can now be used again.`
);
} catch (error) {
createLog(
"error",
"lst",
"serverUpdater",
`There was an error updating the last time the server was updated: ${error}`
);
}
resolve({
success: true,
message: `${server?.toLowerCase()}, has been updated and can now be used again.`,
});
} else {
const errorMessage = `Process exited with code ${code}`;
// if (count >= servers) {
// //onClose(code);
// }
reject({
success: false,
message: `${server?.toLowerCase()}, Has encounted an error while updating.`,
});
}
});
// Handle errors with the process itself
process.on("error", (error) => {
//onError(err.message);
createLog("error", "lst", "serverUpdater", `${error}`);
reject(error);
});
});
}; };
export async function processAllServers(devApp: string) { export async function processAllServers(devApp: string) {
const servers = await db.select().from(serverData); const servers = await db.select().from(serverData);
createLog("info", "lst", "serverUpdater", `Running the update on all servers`); createLog(
let count = 1; "info",
for (const server of servers) { "lst",
try { "serverUpdater",
const updateToServer = await updateServer(devApp, server.plantToken); `Running the update on all servers`
createLog("info", "lst", "serverUpdater", `${server.sName} was updated.`); );
count = count + 1; let count = 1;
for (const server of servers) {
try {
const updateToServer = await updateServer(devApp, server.plantToken);
createLog("info", "lst", "serverUpdater", `${server.sName} was updated.`);
count = count + 1;
//return {success: true, message: `${server.sName} was updated.`, data: updateToServer}; //return {success: true, message: `${server.sName} was updated.`, data: updateToServer};
} catch (error: any) { } catch (error: any) {
createLog("info", "lst", "serverUpdater", `Error updating ${server.sName}: ${error.message}`); createLog(
//return {success: false, message: `Error updating ${server.sName}: ${error.message}`}; "info",
} "lst",
"serverUpdater",
`Error updating ${server.sName}: ${error.message}`
);
//return {success: false, message: `Error updating ${server.sName}: ${error.message}`};
} }
}
} }

View File

@@ -99,7 +99,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 "build: bump build number to ${pkgJson.admConfig.build}"` `git commit -m "chore(release): bump build number to ${pkgJson.admConfig.build}"`
); );
} else { } else {
createLog( createLog(

View File

@@ -1,16 +1,21 @@
import axios from "axios"; import axios from "axios";
export const ocmeInv = async (data: any) => { export const ocmeInv = async (data: any) => {
try { try {
const res = await axios.post( const res = await axios.post(
"http://usday1vms010:3250/api/v1/getLaneData", "http://usday1vms010:3250/api/v1/getlanedata",
{lane: data.lane, laneType: data.laneType}, { lane: data.lane, laneType: data.laneType },
{headers: {"Content-Type": "application/json", Connection: "keep-alive"}} {
); headers: {
// console.log(res.data.data); "Content-Type": "application/json",
Connection: "keep-alive",
},
}
);
// console.log(res.data.data);
return res.data.data; return res.data.data;
} catch (error: any) { } catch (error: any) {
console.log(error.code); console.log(error.code);
} }
}; };

View File

@@ -1,43 +1,67 @@
import {db} from "../../../../database/dbclient.js"; import { db } from "../../../../database/dbclient.js";
import {ocmeData} from "../../../../database/schema/ocme.js"; import { ocmeData } from "../../../../database/schema/ocme.js";
import {createSSCC} from "../../../globalUtils/createSSCC.js"; 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";
export const postLabelData = async (data: any) => { export const postLabelData = async (data: any) => {
// if we have sscc we will do everything here and ignore the rn even it its sent over console.log(data);
if (data.sscc && !data.runningNr) { let newData = data;
data.runningNr = data.sscc.slice(10, -1); if (Array.isArray(data)) {
} newData = {
sscc: data[1],
if (!data.sscc && !data.runningNr) { areaFrom: data[0],
// data.runningNr = data.sscc.slice(10, -1); completed: true,
return {success: false, message: "Missing data please try again", data: []};
}
let label;
const filterQuery = labelData.replaceAll("[rn]", data.runningNr);
try {
label = await query(filterQuery, "Label data");
} catch (error) {
createLog("error", "ocme", "ocme", "There was an error getting the labelData");
}
const newPost = {
sscc: data.sscc ? data.sscc : await createSSCC(data.runningNr),
runningNr: data.runningNr,
completed: data.completed,
lineNum: label[0].machineLocation,
areaFrom: data.areaFrom,
pickedUp: false,
}; };
}
try { if (newData.sscc && !newData.runningNr) {
const enterNewData = await db.insert(ocmeData).values(newPost).returning({sscc: ocmeData.sscc}); newData.runningNr = newData.sscc.slice(10, -1);
return {success: true, message: "Data was posted to ocme info", data: enterNewData}; }
} catch (error) { if (!newData.sscc && !newData.runningNr) {
console.log(error); return {
return {success: false, message: "Data was posted to ocme info", data: newPost}; success: false,
} message: "Missing data please try again",
data: [],
};
}
let label;
const filterQuery = labelData.replaceAll("[rn]", newData.runningNr);
try {
label = await query(filterQuery, "Label data");
} catch (error) {
createLog(
"error",
"ocme",
"ocme",
"There was an error getting the labelData"
);
}
const newPost = {
sscc: newData.sscc ? newData.sscc : await createSSCC(newData.runningNr),
runningNr: newData.runningNr,
completed: newData.completed,
lineNum: label[0].machineLocation,
areaFrom: newData.areaFrom,
pickedUp: false,
};
try {
const enterNewData = await db
.insert(ocmeData)
.values(newPost)
.returning({ sscc: ocmeData.sscc });
return {
success: true,
message: "Data was posted to ocme info",
data: enterNewData,
};
} catch (error) {
console.log(error);
return {
success: false,
message: "Data was posted to ocme info",
data: newPost,
};
}
}; };

View File

@@ -1,60 +1,71 @@
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 {authMiddleware} from "../../auth/middleware/authMiddleware.js"; import { authMiddleware } from "../../auth/middleware/authMiddleware.js";
import {cycleCount} from "../controller/cycleCount.js"; import { cycleCount } from "../controller/cycleCount.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";
const app = new OpenAPIHono({strict: false}); const app = new OpenAPIHono({ strict: false });
const AddSetting = z.object({ const AddSetting = z.object({
lane: z.string().openapi({example: "L064"}), lane: z.string().openapi({ example: "L064" }),
}); });
app.openapi( app.openapi(
createRoute({ createRoute({
tags: ["ocme"], tags: ["ocme"],
summary: "Cycle counts a lane based on the lane Alias", summary: "Cycle counts a lane based on the lane Alias",
method: "post", method: "post",
path: "/cyclecount", path: "/cycleCount",
middleware: authMiddleware, middleware: authMiddleware,
request: { request: {
body: { body: {
content: { content: {
"application/json": {schema: AddSetting}, "application/json": { schema: AddSetting },
},
},
}, },
responses: responses(), },
}), },
async (c) => { responses: responses(),
apiHit(c, {endpoint: "api/auth/register"}); }),
// make sure we have a vaid user being accessed thats really logged in async (c) => {
const body = await c.req.json(); apiHit(c, { endpoint: "api/auth/register" });
// make sure we have a vaid user being accessed thats really logged in
const body = await c.req.json();
const authHeader = c.req.header("Authorization"); const authHeader = c.req.header("Authorization");
const token = authHeader?.split("Bearer ")[1] || ""; const token = authHeader?.split("Bearer ")[1] || "";
let user: User; let user: User;
try { try {
const payload = await verify(token, process.env.JWT_SECRET!); const payload = await verify(token, process.env.JWT_SECRET!);
user = payload.user as User; user = payload.user as User;
} catch (error) { } catch (error) {
return c.json({message: "Unauthorized"}, 401); return c.json({ message: "Unauthorized" }, 401);
}
try {
const cycleData = await cycleCount(body, user);
return c.json({success: true, message: `${body.lane} was just cycle counted.`, data: cycleData}, 200);
} catch (error) {
return c.json(
{success: false, message: `There was an error cycle counting ${body.lane}`, data: error},
400
);
}
} }
try {
const cycleData = await cycleCount(body, user);
return c.json(
{
success: true,
message: `${body.lane} was just cycle counted.`,
data: cycleData,
},
200
);
} catch (error) {
return c.json(
{
success: false,
message: `There was an error cycle counting ${body.lane}`,
data: error,
},
400
);
}
}
); );
export default app; export default app;

View File

@@ -1,81 +1,96 @@
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi"; import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import {getInfo} from "../controller/getInfo.js"; import { getInfo } from "../controller/getInfo.js";
import {apiHit} from "../../../globalUtils/apiHits.js"; import { apiHit } from "../../../globalUtils/apiHits.js";
const app = new OpenAPIHono({strict: false}); const app = new OpenAPIHono({ strict: false });
const AddSetting = z.object({ const AddSetting = z.object({
name: z.string().openapi({example: "server"}), name: z.string().openapi({ example: "server" }),
value: z.string().openapi({example: "localhost"}), value: z.string().openapi({ example: "localhost" }),
description: z.string().openapi({example: "The server we are going to connect to"}), description: z
roles: z.string().openapi({example: "admin"}), .string()
module: z.string().openapi({example: "production"}), .openapi({ example: "The server we are going to connect to" }),
roles: z.string().openapi({ example: "admin" }),
module: z.string().openapi({ example: "production" }),
}); });
app.openapi( app.openapi(
createRoute({ createRoute({
tags: ["ocme"], tags: ["ocme"],
summary: "Get all current info", summary: "Get all current info",
method: "get", method: "get",
path: "/getinfo", path: "/getInfo",
request: { request: {
body: { body: {
content: { content: {
"application/json": {schema: AddSetting}, "application/json": { schema: AddSetting },
},
},
}, },
responses: { },
200: { },
content: { responses: {
"application/json": { 200: {
schema: z.object({ content: {
success: z.boolean().openapi({example: true}), "application/json": {
message: z.string().openapi({example: "Starter"}), schema: z.object({
data: z.array(z.object({})).optional().openapi({example: []}), success: z.boolean().openapi({ example: true }),
}), message: z.string().openapi({ example: "Starter" }),
}, data: z.array(z.object({})).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) => { },
// make sure we have a vaid user being accessed thats really logged in 400: {
apiHit(c, {endpoint: "api/auth/register"}); content: {
try { "application/json": {
return c.json({success: true, message: "Ocme Info", data: await getInfo()}, 200); schema: z.object({
} catch (error) { success: z.boolean().openapi({ example: false }),
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400); 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
apiHit(c, { endpoint: "api/auth/register" });
try {
return c.json(
{ success: true, message: "Ocme Info", data: await getInfo() },
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

@@ -1,94 +1,114 @@
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 {getShipmentPallets} from "../controller/getShipmentPallets.js"; import { getShipmentPallets } from "../controller/getShipmentPallets.js";
const app = new OpenAPIHono(); const app = new OpenAPIHono();
const ShipmentID = z.object({ const ShipmentID = z.object({
shipmentID: z.string().optional().openapi({example: "14558"}), shipmentID: z.string().optional().openapi({ example: "14558" }),
}); });
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: "/getshipmentpallets", path: "/GetShipmentPallets",
request: { request: {
body: { body: {
content: { content: {
"application/json": {schema: ShipmentID}, "application/json": { schema: ShipmentID },
},
},
}, },
responses: { },
200: { },
content: { responses: {
"application/json": { 200: {
schema: z.object({ content: {
success: z.boolean().openapi({example: true}), "application/json": {
message: z.string().openapi({example: "Starter"}), schema: z.object({
// data: z success: z.boolean().openapi({ example: true }),
// .array(z.object({sscc: z.string().optional()})) message: z.string().openapi({ example: "Starter" }),
// .optional() // data: z
// .openapi({example: []}), // .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",
async (c) => { },
// make sure we have a vaid user being accessed thats really logged in 400: {
try { content: {
const data = await c.req.json(); "application/json": {
apiHit(c, {endpoint: "api/ocme/getshipmentpallets", lastBody: data}); 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/getshipmentpallets", lastBody: data });
if (!data.shipmentID) { console.log;
return c.json(
{success: false, message: "You are missing the shipment id please try again.", data: []},
400
);
}
const shiptmentData = await getShipmentPallets(data.shipmentID); if (!data.shipmentID) {
return c.json(
{
success: false,
message: "You are missing the shipment id please try again.",
data: [],
},
400
);
}
return c.json( const shiptmentData = await getShipmentPallets(data.shipmentID);
{success: shiptmentData.success, message: shiptmentData.message, data: shiptmentData.data ?? []},
200 return c.json(
); {
} catch (error) { success: shiptmentData.success,
return c.json({success: false, message: "There was an error getting the shipment data.", data: error}, 400); message: shiptmentData.message,
} data: shiptmentData.data ?? [],
},
200
);
} catch (error) {
return c.json(
{
success: false,
message: "There was an error getting the shipment data.",
data: error,
},
400
);
} }
}
); );
export default app; export default app;

View File

@@ -1,89 +1,114 @@
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi"; import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import {postLabelData} from "../controller/postRunningNr.js"; import { postLabelData } from "../controller/postRunningNr.js";
import {apiHit} from "../../../globalUtils/apiHits.js"; import { apiHit } from "../../../globalUtils/apiHits.js";
import {pickedup} from "../controller/pickedup.js"; import { pickedup } from "../controller/pickedup.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.string().optional().openapi({example: "The server we are going to connect to"}), areaFrom: z
completed: z.boolean().optional().openapi({example: true}), .string()
all: z.boolean().optional().openapi({example: false}), .optional()
.openapi({ example: "The server we are going to connect to" }),
completed: z.boolean().optional().openapi({ example: true }),
all: z.boolean().optional().openapi({ example: false }),
}); });
app.openapi( app.openapi(
createRoute({ createRoute({
tags: ["ocme"], tags: ["ocme"],
summary: "Picks up a pallet in the system.", summary: "Picks up a pallet in the system.",
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: {
"application/json": {schema: PostRunningNr}, "application/json": { schema: PostRunningNr },
},
},
}, },
responses: { },
200: { },
content: { responses: {
"application/json": { 200: {
schema: z.object({ content: {
success: z.boolean().openapi({example: true}), "application/json": {
message: z.string().openapi({example: "Starter"}), schema: z.object({
// data: z success: z.boolean().openapi({ example: true }),
// .array(z.object({sscc: z.string().optional()})) message: z.string().openapi({ example: "Starter" }),
// .optional() // data: z
// .openapi({example: []}), // .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",
async (c) => { },
// make sure we have a vaid user being accessed thats really logged in 400: {
try { content: {
const data = await c.req.json(); "application/json": {
apiHit(c, {endpoint: "api/ocme/pickedup", lastBody: data}); schema: z.object({
const postPallet = await pickedup(data); success: z.boolean().openapi({ example: false }),
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data}, 200); message: z
} catch (error) { .string()
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400); .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/pickedup", lastBody: data });
const postPallet = await pickedup(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

@@ -1,86 +1,106 @@
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi"; import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import {getInfo} from "../controller/getInfo.js"; import { getInfo } from "../controller/getInfo.js";
import {postLabelData} from "../controller/postRunningNr.js"; import { postLabelData } from "../controller/postRunningNr.js";
import {apiHit} from "../../../globalUtils/apiHits.js"; 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.string().optional().openapi({example: "The server we are going to connect to"}), areaFrom: z
completed: z.boolean().optional().openapi({example: true}), .string()
.optional()
.openapi({ example: "The server we are going to connect to" }),
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: { },
content: { responses: {
"application/json": { 200: {
schema: z.object({ content: {
success: z.boolean().openapi({example: true}), "application/json": {
message: z.string().openapi({example: "Starter"}), schema: z.object({
// data: z success: z.boolean().openapi({ example: true }),
// .array(z.object({sscc: z.string().optional()})) message: z.string().openapi({ example: "Starter" }),
// .optional() // data: z
// .openapi({example: []}), // .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",
async (c) => { },
// make sure we have a vaid user being accessed thats really logged in 400: {
try { content: {
const data = await c.req.json(); "application/json": {
apiHit(c, {endpoint: "api/ocme/postRunningNumber", lastBody: data}); schema: z.object({
const postPallet = await postLabelData(data); success: z.boolean().openapi({ example: false }),
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data ?? []}, 200); message: z
} catch (error) { .string()
return c.json({success: false, message: "There was an error getting ocmeInfo data", data: error}, 400); .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
);
} }
}
); );
export default app; export default app;

View File

@@ -1,64 +1,79 @@
import net from "net"; import net from "net";
import {OpenAPIHono} from "@hono/zod-openapi"; import { OpenAPIHono } from "@hono/zod-openapi";
import {createLog} from "../logger/logger.js"; import { createLog } from "../logger/logger.js";
import startTCP from "./route/startServer.js"; import startTCP from "./route/startServer.js";
import stopTCP from "./route/stopServer.js"; import stopTCP from "./route/stopServer.js";
import restartTCP from "./route/restartServer.js"; import restartTCP from "./route/restartServer.js";
import {db} from "../../../database/dbclient.js"; 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";
let tcpServer: net.Server; let tcpServer: net.Server;
let tcpSockets: Set<net.Socket> = new Set(); let tcpSockets: Set<net.Socket> = new Set();
let isServerRunning = false; let isServerRunning = false;
const tcpPort = await db.select().from(settings).where(eq(settings.name, "tcpPort")); const tcpPort = await db
.select()
.from(settings)
.where(eq(settings.name, "tcpPort"));
const app = new OpenAPIHono(); const app = new OpenAPIHono();
export const startTCPServer = () => { export const startTCPServer = () => {
if (isServerRunning) return {success: false, message: "Server is already running"}; if (isServerRunning)
return { success: false, message: "Server is already running" };
tcpServer = net.createServer((socket) => { tcpServer = net.createServer((socket) => {
console.log("Client connected"); console.log("Client connected");
tcpSockets.add(socket); tcpSockets.add(socket);
socket.on("data", (data: Buffer) => { socket.on("data", (data: Buffer) => {
console.log("Received:", data.toString()); console.log("Received:", data.toString());
socket.write("Message received"); const parseData = data.toString("utf-8").trimEnd().split(" ");
}); if (parseData[0] === "HB") {
return;
socket.on("end", () => { }
console.log("Client disconnected"); postLabelData(parseData);
tcpSockets.delete(socket);
});
socket.on("error", (err: Error) => {
console.error("Socket error:", err);
tcpSockets.delete(socket);
});
}); });
tcpServer.listen(tcpPort[0]?.value ?? 2222, () => { socket.on("end", () => {
createLog("info", "lst", "tcp", `TCP Server listening on port ${tcpPort[0]?.value ?? 2222}`); console.log("Client disconnected");
tcpSockets.delete(socket);
}); });
isServerRunning = true; socket.on("error", (err: Error) => {
return {success: true, message: "TCP Server started"}; console.error("Socket error:", err);
tcpSockets.delete(socket);
});
});
tcpServer.listen(tcpPort[0]?.value ?? 2222, () => {
createLog(
"info",
"lst",
"tcp",
`TCP Server listening on port ${tcpPort[0]?.value ?? 2222}`
);
});
isServerRunning = true;
return { success: true, message: "TCP Server started" };
}; };
// Function to stop the TCP server // Function to stop the TCP server
export const stopTCPServer = () => { export const stopTCPServer = () => {
if (!isServerRunning) return {success: false, message: "Server is not running"}; if (!isServerRunning)
for (const socket of tcpSockets) { return { success: false, message: "Server is not running" };
socket.destroy(); for (const socket of tcpSockets) {
} socket.destroy();
tcpSockets.clear(); }
tcpServer.close(() => { tcpSockets.clear();
console.log("TCP Server stopped"); tcpServer.close(() => {
}); console.log("TCP Server stopped");
isServerRunning = false; });
return {success: true, message: "TCP Server stopped"}; isServerRunning = false;
return { success: true, message: "TCP Server stopped" };
}; };
app.route("/tcpserver/start", startTCP); app.route("/tcpserver/start", startTCP);
@@ -67,7 +82,7 @@ app.route("/tcpserver/restart", restartTCP);
// start the server after on system start up // start the server after on system start up
setTimeout(() => { setTimeout(() => {
startTCPServer(); startTCPServer();
}, 5000); }, 5000);
export default app; export default app;