cobalt/api/src/cobalt.js

33 lines
767 B
JavaScript
Raw Normal View History

import "dotenv/config";
2022-07-08 19:17:56 +01:00
import express from "express";
import cluster from "node:cluster";
import path from "path";
import { fileURLToPath } from "url";
2022-07-08 19:17:56 +01:00
import { env, isCluster } from "./config.js"
import { Red } from "./misc/console-text.js";
import { initCluster } from "./misc/cluster.js";
const app = express();
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");
2024-08-02 16:32:00 +01:00
if (env.apiURL) {
const { runAPI } = await import("./core/api.js");
if (cluster.isPrimary && isCluster) {
initCluster();
}
runAPI(express, app, __dirname, cluster.isPrimary);
2022-07-08 19:17:56 +01:00
} else {
console.log(
Red("API_URL env variable is missing, cobalt api can't start.")
)
}