2023-02-12 07:40:49 +00:00
|
|
|
import "dotenv/config";
|
2024-03-05 13:41:22 +00:00
|
|
|
import "./modules/sub/alias-envs.js";
|
2022-07-08 19:17:56 +01:00
|
|
|
|
|
|
|
import express from "express";
|
2023-04-29 12:40:08 +01:00
|
|
|
|
2023-05-21 20:13:05 +01:00
|
|
|
import { Bright, Green, Red } from "./modules/sub/consoleText.js";
|
|
|
|
import { getCurrentBranch, shortCommit } from "./modules/sub/currentCommit.js";
|
|
|
|
import { loadLoc } from "./localization/manager.js";
|
2022-07-08 19:17:56 +01:00
|
|
|
|
2023-03-09 18:41:17 +00:00
|
|
|
import path from 'path';
|
|
|
|
import { fileURLToPath } from 'url';
|
2022-07-08 19:17:56 +01:00
|
|
|
|
2023-05-21 20:13:05 +01:00
|
|
|
const app = express();
|
2022-07-10 15:04:03 +01:00
|
|
|
|
2023-05-21 20:13:05 +01:00
|
|
|
const gitCommit = shortCommit();
|
|
|
|
const gitBranch = getCurrentBranch();
|
2022-07-08 19:17:56 +01:00
|
|
|
|
2023-05-21 20:13:05 +01:00
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
2023-06-27 14:56:15 +01:00
|
|
|
const __dirname = path.dirname(__filename).slice(0, -4);
|
2023-02-12 07:40:49 +00:00
|
|
|
|
2023-05-21 20:13:05 +01:00
|
|
|
app.disable('x-powered-by');
|
2023-02-12 07:40:49 +00:00
|
|
|
|
2023-06-27 14:56:15 +01:00
|
|
|
await loadLoc();
|
2023-02-12 07:40:49 +00:00
|
|
|
|
2024-03-05 13:08:59 +00:00
|
|
|
const apiMode = process.env.API_URL && !process.env.WEB_URL;
|
|
|
|
const webMode = process.env.WEB_URL && process.env.API_URL;
|
2023-07-02 02:02:15 +01:00
|
|
|
|
|
|
|
if (apiMode) {
|
2023-08-24 07:36:38 +01:00
|
|
|
const { runAPI } = await import('./core/api.js');
|
2023-08-04 19:43:12 +01:00
|
|
|
runAPI(express, app, gitCommit, gitBranch, __dirname)
|
2023-07-02 02:02:15 +01:00
|
|
|
} else if (webMode) {
|
2023-08-24 07:36:38 +01:00
|
|
|
const { runWeb } = await import('./core/web.js');
|
2023-08-04 19:43:12 +01:00
|
|
|
await runWeb(express, app, gitCommit, gitBranch, __dirname)
|
2022-07-08 19:17:56 +01:00
|
|
|
} else {
|
2023-12-02 16:01:58 +00:00
|
|
|
console.log(
|
|
|
|
Red(`cobalt wasn't configured yet or configuration is invalid.\n`)
|
|
|
|
+ Bright(`please run the setup script to fix this: `)
|
|
|
|
+ Green(`npm run setup`)
|
|
|
|
)
|
2022-08-01 16:48:37 +01:00
|
|
|
}
|