refactor(controller): converted to socket.io
This commit is contained in:
@@ -3,16 +3,16 @@ import morgan from "morgan";
|
||||
import { createServer } from "http";
|
||||
import { setupRoutes } from "./internal/routerHandler/routeHandler.js";
|
||||
import { printers } from "./internal/ocp/printers/printers.js";
|
||||
import path, { dirname, join } from "path";
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { db } from "./pkg/db/db.js";
|
||||
import { settings, type Setting } from "./pkg/db/schema/settings.js";
|
||||
import { settings } from "./pkg/db/schema/settings.js";
|
||||
import { validateEnv } from "./pkg/utils/envValidator.js";
|
||||
import { createLogger } from "./pkg/logger/logger.js";
|
||||
import { returnFunc } from "./pkg/utils/return.js";
|
||||
import { closePool, initializeProdPool } from "./pkg/prodSql/prodSqlConnect.js";
|
||||
import { initializeProdPool } from "./pkg/prodSql/prodSqlConnect.js";
|
||||
import { tryCatch } from "./pkg/utils/tryCatch.js";
|
||||
import os, { hostname } from "os";
|
||||
import os from "os";
|
||||
import { sendNotify } from "./pkg/utils/notify.js";
|
||||
|
||||
const main = async () => {
|
||||
@@ -24,10 +24,6 @@ const main = async () => {
|
||||
// base path
|
||||
let basePath: string = "";
|
||||
|
||||
if (process.env.NODE_ENV?.trim() !== "production") {
|
||||
basePath = "/lst";
|
||||
}
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
@@ -47,14 +43,14 @@ const main = async () => {
|
||||
|
||||
if (res.data.length === 0) {
|
||||
//return
|
||||
returnFunc({
|
||||
success: false,
|
||||
module: "system",
|
||||
level: "fatal",
|
||||
message: `This seems to be the first time you have started the app please validate the settings have been intiated`,
|
||||
notify: false,
|
||||
data: [],
|
||||
});
|
||||
// returnFunc({
|
||||
// success: false,
|
||||
// module: "system",
|
||||
// level: "fatal",
|
||||
// message: `This seems to be the first time you have started the app please validate the settings have been intiated`,
|
||||
// notify: false,
|
||||
// data: [],
|
||||
// });
|
||||
}
|
||||
|
||||
// connect to the prod sql
|
||||
@@ -64,22 +60,22 @@ const main = async () => {
|
||||
const app = express();
|
||||
|
||||
// global middleware
|
||||
app.use(express.static(path.join(__dirname, "../lstDocs/build")));
|
||||
app.use(express.static(path.join(__dirname, "../frontend/dist")));
|
||||
app.use(express.json());
|
||||
|
||||
// global env that run only in dev
|
||||
if (process.env.NODE_ENV?.trim() !== "production") {
|
||||
app.use(morgan("tiny"));
|
||||
basePath = "/lst";
|
||||
}
|
||||
|
||||
// docs and api stuff
|
||||
app.use(
|
||||
basePath + "/d",
|
||||
express.static(join(__dirname, "../lstDocs/build"))
|
||||
express.static(join(__dirname, "../../lstDocs/build"))
|
||||
);
|
||||
app.use(
|
||||
basePath + "/app",
|
||||
express.static(join(__dirname, "../frontend/dist"))
|
||||
express.static(join(__dirname, "../../frontend/dist"))
|
||||
);
|
||||
|
||||
// register app
|
||||
@@ -129,7 +125,7 @@ const main = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
//process.exit(1);
|
||||
});
|
||||
|
||||
// setInterval(() => {
|
||||
@@ -145,12 +141,3 @@ const main = async () => {
|
||||
};
|
||||
|
||||
main();
|
||||
|
||||
// .catch((err) => {
|
||||
// const log = createLogger({ module: "system", subModule: "main" });
|
||||
// log.fatal(
|
||||
// { notify: true },
|
||||
// "There was a crash that occured and caused the app to restart."
|
||||
// );
|
||||
// process.exit(1);
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user