cobalt/api/src/cobalt.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

import "dotenv/config";
import "./modules/sub/alias-envs.js";
2022-07-08 19:17:56 +01:00
import express from "express";
import { Bright, Green, Red } from "./modules/sub/consoleText.js";
import { getCurrentBranch, shortCommit } from "./modules/sub/currentCommit.js";
import { loadLoc } from "./localization/manager.js";
import { mode } from "./modules/config.js"
2022-07-08 19:17:56 +01:00
import path from 'path';
import { fileURLToPath } from 'url';
2022-07-08 19:17:56 +01:00
const app = express();
const gitCommit = shortCommit();
const gitBranch = getCurrentBranch();
2022-07-08 19:17:56 +01:00
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename).slice(0, -4);
app.disable('x-powered-by');
await loadLoc();
if (mode === 'API') {
const { runAPI } = await import('./core/api.js');
2023-08-04 19:43:12 +01:00
runAPI(express, app, gitCommit, gitBranch, __dirname)
} else if (mode === 'WEB') {
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 {
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`)
)
}