refactor(lst): added huston backin

This commit is contained in:
2025-03-30 10:09:32 -05:00
parent a647d05d3b
commit 11e5cf4d86
3 changed files with 114 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
import {OpenAPIHono} from "@hono/zod-openapi"; import { OpenAPIHono } from "@hono/zod-openapi";
import {areModulesIn} from "./utils/moduleCheck.js"; import { areModulesIn } from "./utils/moduleCheck.js";
// routes // routes
import getModules from "./route/modules/getModules.js"; import getModules from "./route/modules/getModules.js";
@@ -8,16 +8,18 @@ import addModule from "./route/modules/addModule.js";
import addSetting from "./route/settings/addSetting.js"; import addSetting from "./route/settings/addSetting.js";
import getSettings from "./route/settings/getSettings.js"; import getSettings from "./route/settings/getSettings.js";
import updateSetting from "./route/settings/updateSetting.js"; import updateSetting from "./route/settings/updateSetting.js";
import {areSettingsIn} from "./utils/settingsCheck.js"; import { areSettingsIn } from "./utils/settingsCheck.js";
import {serversCheckPoint} from "./utils/serverData.js"; import { serversCheckPoint } from "./utils/serverData.js";
import getServers from "./route/servers/getServers.js"; import getServers from "./route/servers/getServers.js";
import updateServer from "./route/updates/updateServer.js"; import updateServer from "./route/updates/updateServer.js";
import { setPerms } from "./utils/testServerPerms.js";
// making sure all modules are in properly // making sure all modules are in properly
setTimeout(() => { setTimeout(async () => {
areSettingsIn(); await areSettingsIn();
areModulesIn(); await areModulesIn();
serversCheckPoint(); await serversCheckPoint();
await setPerms();
}, 5000); }, 5000);
const app = new OpenAPIHono(); const app = new OpenAPIHono();
@@ -41,6 +43,10 @@ const appRoutes = routes.forEach((route) => {
}); });
app.all("/server/*", (c) => { app.all("/server/*", (c) => {
return c.json({success: false, message: "You encountered a route that dose not exist on the server routes"}); return c.json({
success: false,
message:
"You encountered a route that dose not exist on the server routes",
});
}); });
export default app; export default app;

View File

@@ -18,7 +18,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Bethlehem", "sName": "Bethlehem",
@@ -38,7 +38,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Huston", "sName": "Huston",
@@ -53,12 +53,12 @@
"contactPhone": "6366970253", "contactPhone": "6366970253",
"customerTiAcc": "ALPL01HOUSINT", "customerTiAcc": "ALPL01HOUSINT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Bowling Green 1", "sName": "Bowling Green 1",
@@ -78,7 +78,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Iowa ISBM", "sName": "Iowa ISBM",
@@ -98,7 +98,7 @@
"oldVersion": "E:\\LST\\lst_backend_2", "oldVersion": "E:\\LST\\lst_backend_2",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Kansas City", "sName": "Kansas City",
@@ -118,7 +118,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Bowling Green 2", "sName": "Bowling Green 2",
@@ -133,12 +133,12 @@
"contactPhone": "6366970253", "contactPhone": "6366970253",
"customerTiAcc": "ALPL01BG2INT", "customerTiAcc": "ALPL01BG2INT",
"lstServerPort": "4000", "lstServerPort": "4000",
"active": false, "active": true,
"serverLoc": "E:\\LST\\lstv2", "serverLoc": "E:\\LST\\lstv2",
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "MCDonough", "sName": "MCDonough",
@@ -158,7 +158,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Dayton", "sName": "Dayton",
@@ -178,7 +178,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Salt Lake City", "sName": "Salt Lake City",
@@ -198,7 +198,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Lima", "sName": "Lima",
@@ -218,7 +218,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Florence", "sName": "Florence",
@@ -238,7 +238,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Iowa EBM", "sName": "Iowa EBM",
@@ -258,7 +258,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Jefferson city", "sName": "Jefferson city",
@@ -278,7 +278,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "Sherman", "sName": "Sherman",
@@ -298,7 +298,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
}, },
{ {
"sName": "West Bend", "sName": "West Bend",
@@ -318,7 +318,9 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti", "active": false}] "otherSettings": [
{ "specialInstructions": "something for ti", "active": false }
]
}, },
{ {
"sName": "St Peters", "sName": "St Peters",
@@ -338,7 +340,7 @@
"oldVersion": "E:\\LST\\lst_backend", "oldVersion": "E:\\LST\\lst_backend",
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]", "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]", "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
"otherSettings": [{"specialInstructions": "something for ti"}] "otherSettings": [{ "specialInstructions": "something for ti" }]
} }
] ]
} }

View File

@@ -0,0 +1,78 @@
import { spawn } from "child_process";
import { createLog } from "../../logger/logger.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import { db } from "../../../../database/dbclient.js";
import { settings } from "../../../../database/schema/settings.js";
import { eq } from "drizzle-orm";
export const setPerms = async () => {
const { data, error } = await tryCatch(
db.select().from(settings).where(eq(settings.name, "server"))
);
if (error) {
return createLog(
"error",
"lst",
"serverUpdater",
`Error getting the server settings`
);
}
if (data[0].value != "usmcd1vms036") {
return createLog(
"info",
"lst",
"serverUpdater",
`${data[0].value} will not have its permissions updated as it is not the test server.`
);
}
const scriptPath = `E:\\LST\\lstv2\\server\\scripts\\update.ps1 `;
const args = [
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-File",
scriptPath,
];
const process = spawn("powershell", args);
// Collect stdout data
process.stdout.on("data", (data) => {
const output = data.toString().trim();
createLog("info", "lst", "serverUpdater", `${output}`);
//onData(output);
});
// 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", `Finished setting perms`);
//update the last build.
} else {
const errorMessage = `Process exited with code ${code}`;
// if (count >= servers) {
// //onClose(code);
// }
}
});
// Handle errors with the process itself
process.on("error", (error) => {
//onError(err.message);
createLog("error", "lst", "serverUpdater", `${error}`);
});
};