Compare commits

...

6 Commits

13 changed files with 9216 additions and 12502 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@
"checkupdates": "npm-check-updates"
},
"dependencies": {
"@hookform/resolvers": "^4.1.2",
"@hookform/resolvers": "^4.1.3",
"@radix-ui/react-avatar": "^1.1.3",
"@radix-ui/react-checkbox": "^1.1.4",
"@radix-ui/react-collapsible": "^1.1.3",
@@ -25,46 +25,46 @@
"@radix-ui/react-slot": "^1.1.2",
"@radix-ui/react-tabs": "^1.1.3",
"@radix-ui/react-tooltip": "^1.1.8",
"@tailwindcss/vite": "^4.0.9",
"@tanstack/react-query": "^5.66.9",
"@tanstack/react-router": "^1.111.11",
"@tailwindcss/vite": "^4.0.15",
"@tanstack/react-query": "^5.69.0",
"@tanstack/react-router": "^1.114.27",
"@tanstack/react-table": "^8.21.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"dotenv": "^16.4.7",
"hono": "^4.7.2",
"hono": "^4.7.5",
"js-cookie": "^3.0.5",
"jsonwebtoken": "^9.0.2",
"lucide-react": "^0.476.0",
"next-themes": "^0.4.4",
"npm-check-updates": "^17.1.15",
"lucide-react": "^0.483.0",
"next-themes": "^0.4.6",
"npm-check-updates": "^17.1.16",
"react": "^19.0.0",
"react-day-picker": "^8.10.1",
"react-dom": "^19.0.0",
"react-grid-layout": "^1.5.0",
"react-grid-layout": "^1.5.1",
"react-hook-form": "^7.54.2",
"sonner": "^2.0.1",
"tailwind-merge": "^3.0.2",
"tailwindcss": "^4.0.9",
"tailwindcss": "^4.0.15",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.24.2",
"zustand": "^5.0.3"
},
"devDependencies": {
"@eslint/js": "^9.21.0",
"@tanstack/router-devtools": "^1.106.0",
"@tanstack/router-plugin": "^1.106.0",
"@types/react": "^19.0.10",
"@eslint/js": "^9.23.0",
"@tanstack/router-devtools": "^1.114.27",
"@tanstack/router-plugin": "^1.114.27",
"@types/react": "^19.0.12",
"@types/react-dom": "^19.0.4",
"@types/react-grid-layout": "^1.3.5",
"@vitejs/plugin-react-swc": "^3.8.0",
"eslint": "^9.21.0",
"eslint-plugin-react-hooks": "^5.0.0",
"@vitejs/plugin-react-swc": "^3.8.1",
"eslint": "^9.23.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^15.15.0",
"typescript": "~5.7.2",
"typescript-eslint": "^8.24.1",
"vite": "^6.2.0"
"globals": "^16.0.0",
"typescript": "~5.8.2",
"typescript-eslint": "^8.27.0",
"vite": "^6.2.2"
}
}

View File

@@ -1,19 +1,22 @@
//import {useEffect, useState} from "react";
import {LstCard} from "../extendedUI/LstCard";
import {CardContent, CardHeader} from "../ui/card";
import {Skeleton} from "../ui/skeleton";
import {Button} from "../ui/button";
import {toast} from "sonner";
// //import {useEffect, useState} from "react";
// import {LstCard} from "../extendedUI/LstCard";
// import {CardContent, CardHeader} from "../ui/card";
// import {Skeleton} from "../ui/skeleton";
// import {Button} from "../ui/button";
// import {toast} from "sonner";
// import {useEffect} from "react";
export default function CycleCountLog() {
//const [logs, setLogs] = useState([]);
//const [streaming, setStreaming] = useState(false); // Track if streaming is active
// export default function CycleCountLog() {
// //const [logs, setLogs] = useState([]);
// //const [streaming, setStreaming] = useState(false); // Track if streaming is active
// useEffect(() => {
// // Start streaming when the button is clicked
// let es;
// es = new EventSource("http://localhost:4000/api/logger/logs/stream?service=ocme-count&level=info");
// const url = `http://localhost:4000/api/log`;
// es = new EventSource(url, {withCredentials: true});
// es.onopen = () => console.log(">>> Connection opened!");
// es.onerror = (e) => console.log("ERROR!", e);
// es.onmessage = (e) => {
@@ -21,26 +24,26 @@ export default function CycleCountLog() {
// };
// return () => es.close();
// }, []); // Effect runs when `streaming` state changes
// }, []);
// const handleStartStreaming = () => {
// setStreaming(true); // Start streaming when button is clicked
// };
return (
<LstCard className="w-48">
<CardHeader className="flex justify-center">
<span>Cycle Count logs</span>
</CardHeader>
<CardContent>
{Array(10)
.fill(0)
.map((_, i) => (
<div key={i}>
<Skeleton className="m-2 h-4" />
</div>
))}
</CardContent>
<Button onClick={() => toast.success("SOmething")}>Start Stream</Button>
</LstCard>
);
}
// // const handleStartStreaming = () => {
// // setStreaming(true); // Start streaming when button is clicked
// // };
// return (
// <LstCard className="w-48">
// <CardHeader className="flex justify-center">
// <span>Cycle Count logs</span>
// </CardHeader>
// <CardContent>
// {Array(10)
// .fill(0)
// .map((_, i) => (
// <div key={i}>
// <Skeleton className="m-2 h-4" />
// </div>
// ))}
// </CardContent>
// <Button onClick={() => toast.success("SOmething")}>Start Stream</Button>
// </LstCard>
// );
// }

View File

@@ -5,19 +5,20 @@ import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
destructive:
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
ghost:
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
link: "text-primary underline-offset-4 hover:underline",
},
size: {

View File

@@ -18,8 +18,16 @@ export default defineConfig({
},
server: {
proxy: {
"/api": {target: `http://localhost:${Number(process.env.VITE_SERVER_PORT || 4400)}`, changeOrigin: true},
"/ocme": {target: `http://localhost:${Number(process.env.VITE_SERVER_PORT || 4400)}`, changeOrigin: true},
"/api": {
target: `http://localhost:${Number(process.env.VITE_SERVER_PORT || 4400)}`,
changeOrigin: true,
secure: false,
},
"/ocme": {
target: `http://localhost:${Number(process.env.VITE_SERVER_PORT || 4400)}`,
changeOrigin: true,
secure: false,
},
},
},
});

3736
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -22,30 +22,32 @@
"prodBuild": "npm run v1Build && powershell -ExecutionPolicy Bypass -File server/scripts/build.ps1 -dir \"C:\\Users\\matthes01\\Documents\\lstv2\" && npm run zipServer",
"commit": "cz",
"prodinstall": "npm i --omit=dev && npm run db:migrate",
"checkupdates": "npm-check-updates"
"checkupdates": "npx npm-check-updates"
},
"dependencies": {
"@dotenvx/dotenvx": "^1.38.3",
"@hono/node-server": "^1.13.8",
"@hono/zod-openapi": "^0.18.4",
"@scalar/hono-api-reference": "^0.5.175",
"@types/jsonwebtoken": "^9.0.8",
"@dotenvx/dotenvx": "^1.39.0",
"@hono/node-server": "^1.14.0",
"@hono/node-ws": "^1.1.0",
"@hono/zod-openapi": "^0.19.2",
"@scalar/hono-api-reference": "^0.7.2",
"@types/jsonwebtoken": "^9.0.9",
"@types/ws": "^8.18.0",
"adm-zip": "^0.5.16",
"axios": "^1.7.9",
"axios": "^1.8.4",
"bcrypt": "^5.1.1",
"compression": "^1.8.0",
"cookie": "^1.0.2",
"date-fns": "^4.1.0",
"dotenv": "^16.4.7",
"drizzle-kit": "^0.30.4",
"drizzle-orm": "^0.39.3",
"drizzle-kit": "^0.30.5",
"drizzle-orm": "^0.41.0",
"drizzle-zod": "^0.7.0",
"fast-xml-parser": "^5.0.9",
"jsonwebtoken": "^9.0.2",
"mssql": "^11.0.1",
"nodemailer": "^6.10.0",
"nodemailer-express-handlebars": "^7.0.0",
"pg": "^8.13.3",
"pg": "^8.14.1",
"pino": "^9.6.0",
"pino-abstract-transport": "^2.0.0",
"pino-pretty": "^13.0.0",
@@ -57,15 +59,15 @@
"@types/bcrypt": "^5.0.2",
"@types/js-cookie": "^3.0.6",
"@types/mssql": "^9.1.7",
"@types/node": "^22.13.5",
"@types/node": "^22.13.11",
"@types/pg": "^8.11.11",
"concurrently": "^8.2.0",
"concurrently": "^9.1.2",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^16.3.1",
"dotenv": "^16.4.7",
"rimraf": "^6.0.1",
"standard-version": "^9.5.0",
"tsx": "^4.7.1",
"typescript": "~5.7.3"
"tsx": "^4.19.3",
"typescript": "~5.8.2"
},
"config": {
"commitizen": {

View File

@@ -22,6 +22,8 @@ import ocpService from "./services/ocp/ocpService.js";
import {db} from "../database/dbclient.js";
import {settings} from "../database/schema/settings.js";
import {count, eq} from "drizzle-orm";
import {createNodeWebSocket} from "@hono/node-ws";
import {streamSSE} from "hono/streaming";
// create the main prodlogin here
const username = "lst_user";
@@ -34,6 +36,7 @@ export const installed = serverIntialized[0].count === 0 && process.env.NODE_ENV
createLog("info", "LST", "server", `Server is installed: ${installed}`);
const app = new OpenAPIHono({strict: false});
export const {injectWebSocket, upgradeWebSocket} = createNodeWebSocket({app});
// middle ware
app.use("*", logger());
@@ -70,6 +73,39 @@ app.doc("/api/ref", {
},
});
app.get(
"/api/log",
// upgradeWebSocket(() => {
// return {
// onMessage(event, ws) {
// console.log(`Message from client: ${event.data}`);
// ws.send("Hello from server!");
// },
// onClose: () => {
// console.log("Connection closed");
// },
// };
// })
async (c) => {
let id = 0;
let running = true;
return streamSSE(c, async (stream) => {
while (running) {
const message = `It is ${new Date().toISOString()}`;
await stream.writeSSE({
data: message,
event: "time-update",
id: String(id++),
});
await stream.sleep(1000);
if (id === 5) {
running = false;
}
}
});
}
);
const routes = [
scalar,
auth,
@@ -149,6 +185,7 @@ process.on("beforeExit", async () => {
});
const port = process.env.NODE_ENV === "development" ? process.env.VITE_SERVER_PORT : process.env.PROD_PORT;
injectWebSocket(
serve(
{
fetch: app.fetch,
@@ -158,6 +195,7 @@ serve(
(info) => {
createLog("info", "LST", "server", `Server is running on http://${info.address}:${info.port}`);
}
)
);
export type AppRoutes = typeof appRoutes;

View File

@@ -254,16 +254,29 @@ API_KEY= "E3ECD3619A943B98C6F33E3322362"
Write-Host "Creating the env file in the front end"
$envContentTemplateb = @"
DATABASE_URL="file:E:\LST\db\lstBackendDB.db"
DATABASE_URL="file:E:\LST\db\{dbLink}.db"
"@
try {
$dbLink = "lstBackendDB"
if ($token -eq "usiow2") {
$dbLink = "lstBackendDB_2"
}
if ($token -in @("test1", "test2", "test3")) {
$dbLink = "lstBackendDB"
}
# Replace {url} with the actual $url
$envContentb = $envContentTemplateb -replace "{dbLink}", $dbLink
# Define the path where the .env file should be created
$envFilePathb = $obslst + "\packages\database\.env"
# Write the content to the .env file
$envContentTemplateb | Out-File -FilePath $envFilePathb -Encoding UTF8 -Force
$envContentb | Out-File -FilePath $envFilePathb -Encoding UTF8 -Force
# Optional: Verify the file was created
if (Test-Path $envFilePathb) {
@@ -287,12 +300,19 @@ NODE_ENV = production
# server apiKey
API_KEY = E3ECD3619A943B98C6F33E3322362
# Prisma DB link
DATABASE_URL="file:E:\LST\db\lstBackendDB.db"
DATABASE_URL="file:E:\LST\db\{dbLink}.db"
# if you still want the db in the same folder as the server install you need to do like the example below else use the relevent link
DATEBASE_LOC="E:\LST\db\lstBackendDB.db"
DATEBASE_LOC="E:\LST\db\{dbLink}.db"
DATABASE_BACKUP_LOC="E:\LST\backups"
# Server port
SERVER_PORT = 4400
GATEWAY_PORT={gatewayport}
AUTH_PORT=4100
SYSTEM_APP_PORT={systemport}
OCME_PORT={ocme}
# This should me removed once we have the entire app broke out to its own apps
OLD_APP_PORT={appPort}
# Logging
LOG_LEVEL = info
LOG_LOC ="E:\\LST\\logs"
@@ -312,11 +332,37 @@ RESET_TOKEN = 330
try {
$dbLink = "lstBackendDB"
$gatewayport = "4400"
$systemport = "4200"
$ocmeport = "4300"
$appport = "4900"
if ($token -eq "usiow2") {
$dbLink = "lstBackendDB_2"
$gatewayport = "4401"
$systemport = "4201"
$ocmeport = "4301"
$appport = "4901"
}
if ($token -in @("test1", "test2", "test3")) {
$dbLink = "lstBackendDB"
}
#
$port1 = $envContentTemplated -replace "{gatewayport}", $gatewayport
$port2 = $port1 -replace "{systemport}", $systemport
$port3 = $port2 -replace "{ocme}", $ocmeport
$port4 = $port3 -replace "{appPort}", $appport
$envContentd = $port4 -replace "{dbLink}", $dbLink
# Define the path where the .env file should be created
$envFilePathd = $obslst + "\.env"
# Write the content to the .env file
$envContentTemplated | Out-File -FilePath $envFilePathd -Encoding UTF8 -Force
$envContentd | Out-File -FilePath $envFilePathd -Encoding UTF8 -Force
# Optional: Verify the file was created
if (Test-Path $envFilePathd) {

View File

@@ -55,9 +55,9 @@ app.get(
"nsurlsession",
"undici",
],
spec: {
url: "/api/ref",
},
baseServerURL: "https://scalar.com",
servers: [
{

View File

@@ -1,7 +1,7 @@
import type {Context} from "hono";
import {db} from "../../../../database/dbclient.js";
import {and, eq, gt} from "drizzle-orm";
import {streamSSE} from "hono/streaming";
import {streamSSE, streamText} from "hono/streaming";
import {logs} from "../../../../database/schema/logs.js";
export async function streamLogs(c: Context) {

View File

@@ -29,6 +29,11 @@ app.openapi(
}),
async (c) => {
apiHit(c, {endpoint: `api/logger/logs`});
c.header("Access-Control-Allow-Origin", "*"); // Or restrict to a specific origin
c.header("Access-Control-Allow-Headers", "Content-Type");
c.header("Content-Type", "text/event-stream");
c.header("Cache-Control", "no-cache");
c.header("Connection", "keep-alive");
return streamLogs(c);
}
);

View File

@@ -1,7 +1,7 @@
{
"servers": [
{
"sName": "test",
"sName": "Test",
"serverDNS": "usmcd1vms036",
"plantToken": "test3",
"idAdress": "10.193.0.56",
@@ -33,7 +33,7 @@
"contactPhone": "6366970253",
"customerTiAcc": "ALPL01BETHINT",
"lstServerPort": "4000",
"active": false,
"active": true,
"serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",