2024-05-19 22:01:26 +02:00
|
|
|
/*
|
2024-05-26 17:16:20 +02:00
|
|
|
* translation
|
2024-05-19 22:01:26 +02:00
|
|
|
*/
|
|
|
|
|
|
2024-05-10 22:38:47 +02:00
|
|
|
import i18next from "i18next";
|
|
|
|
|
import resourcesToBackend from "i18next-resources-to-backend";
|
|
|
|
|
|
|
|
|
|
i18next.use(resourcesToBackend((language: string, namespace: string) => import(`../../shared-operations/public/locales/${namespace}/${language}.json`)))
|
|
|
|
|
.init({
|
2024-05-26 17:16:20 +02:00
|
|
|
debug: false,
|
2024-05-10 22:38:47 +02:00
|
|
|
ns: ["common"], // Preload this namespace, no need to add the others, they will load once their module is loaded
|
|
|
|
|
defaultNS: "common",
|
|
|
|
|
fallbackLng: "en",
|
|
|
|
|
interpolation: {
|
|
|
|
|
escapeValue: false,
|
|
|
|
|
},
|
|
|
|
|
initImmediate: false // Makes loading blocking but sync
|
|
|
|
|
});
|
2023-12-30 02:18:07 +01:00
|
|
|
|
2024-05-19 22:01:26 +02:00
|
|
|
// list available modules
|
|
|
|
|
import { listOperatorNames } from "@stirling-pdf/shared-operations/src/workflow/operatorAccessor";
|
|
|
|
|
console.log("Available Modules: ", listOperatorNames());
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* jobs
|
|
|
|
|
*/
|
|
|
|
|
|
2024-05-30 01:03:15 +02:00
|
|
|
if(import.meta.env.VITE_JOBS_ENABLED === "True")
|
2024-05-29 23:45:56 +02:00
|
|
|
import("./jobs/jobs-controller");
|
2024-05-19 22:01:26 +02:00
|
|
|
|
2024-05-29 23:19:07 +02:00
|
|
|
/**
|
|
|
|
|
* database
|
|
|
|
|
*/
|
|
|
|
|
|
2024-05-30 01:03:15 +02:00
|
|
|
if(import.meta.env.VITE_AUTH_ENABLED === "True")
|
2024-05-29 23:45:56 +02:00
|
|
|
import("./data/sequelize-relations");
|
2024-05-29 23:19:07 +02:00
|
|
|
|
2024-05-19 22:01:26 +02:00
|
|
|
/*
|
2024-05-26 17:16:20 +02:00
|
|
|
* EXPRESS
|
2024-05-19 22:01:26 +02:00
|
|
|
*/
|
|
|
|
|
|
2024-01-04 20:17:54 -05:00
|
|
|
import express from "express";
|
2023-10-16 23:11:33 +02:00
|
|
|
const app = express();
|
2023-11-10 23:41:31 +03:00
|
|
|
const PORT = 8000;
|
2023-10-26 21:53:02 +03:00
|
|
|
|
2024-05-30 01:03:15 +02:00
|
|
|
import api from "./routes/api/api-controller";
|
|
|
|
|
|
2024-05-26 17:16:20 +02:00
|
|
|
/*
|
2024-05-30 01:03:15 +02:00
|
|
|
* auth
|
2024-05-26 17:16:20 +02:00
|
|
|
*/
|
|
|
|
|
|
2024-05-30 02:08:21 +02:00
|
|
|
console.log("env", import.meta.env)
|
2024-05-26 17:16:20 +02:00
|
|
|
|
2024-05-30 01:03:15 +02:00
|
|
|
if(import.meta.env.VITE_AUTH_ENABLED === "True") {
|
2024-05-30 02:08:21 +02:00
|
|
|
console.log("Attatching Auth")
|
|
|
|
|
import("./auth/auth-controller").then(router => router.connect(app)).finally(() => {
|
2024-05-30 01:03:15 +02:00
|
|
|
/*
|
|
|
|
|
* api
|
|
|
|
|
*/
|
2024-05-26 17:16:20 +02:00
|
|
|
|
2024-05-30 01:03:15 +02:00
|
|
|
app.use("/api", api);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
app.use("/api", api);
|
|
|
|
|
}
|
2023-11-08 02:11:49 +03:00
|
|
|
|
2024-05-19 22:01:26 +02:00
|
|
|
// viteNode
|
2024-08-31 21:55:25 +02:00
|
|
|
if (import.meta.env.PROD) {
|
2024-05-10 22:38:47 +02:00
|
|
|
app.listen(PORT, () => {
|
|
|
|
|
console.log(`http://localhost:${PORT}`);
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-01-04 20:17:54 -05:00
|
|
|
|
|
|
|
|
process.on('unhandledRejection', (reason, promise) => {
|
2024-01-26 16:26:04 +01:00
|
|
|
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
2024-01-04 20:17:54 -05:00
|
|
|
});
|
2024-05-10 22:38:47 +02:00
|
|
|
|
|
|
|
|
export const viteNodeApp = app;
|