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

@@ -12,12 +12,14 @@ 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

@@ -53,7 +53,7 @@
"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\"}]",
@@ -133,7 +133,7 @@
"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\"}]",
@@ -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",

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}`);
});
};