2023-02-12 07:40:49 +00:00
|
|
|
import "dotenv/config";
|
2022-07-08 18:17:56 +00:00
|
|
|
|
|
|
|
import express from "express";
|
2023-04-29 11:40:08 +00:00
|
|
|
|
2023-03-09 18:41:17 +00:00
|
|
|
import path from 'path';
|
|
|
|
import { fileURLToPath } from 'url';
|
2022-07-08 18:17:56 +00:00
|
|
|
|
2024-08-03 15:34:02 +00:00
|
|
|
import { env } from "./config.js"
|
|
|
|
import { Bright, Green, Red } from "./misc/console-text.js";
|
2022-07-10 14:04:03 +00:00
|
|
|
|
2024-08-03 15:34:02 +00:00
|
|
|
const app = express();
|
2022-07-08 18:17:56 +00:00
|
|
|
|
2023-05-21 19:13:05 +00:00
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
2023-06-27 13:56:15 +00:00
|
|
|
const __dirname = path.dirname(__filename).slice(0, -4);
|
2023-02-12 07:40:49 +00:00
|
|
|
|
2023-05-21 19:13:05 +00:00
|
|
|
app.disable('x-powered-by');
|
2023-02-12 07:40:49 +00:00
|
|
|
|
2024-08-02 15:32:00 +00:00
|
|
|
if (env.apiURL) {
|
2023-08-24 06:36:38 +00:00
|
|
|
const { runAPI } = await import('./core/api.js');
|
2024-08-03 15:34:02 +00:00
|
|
|
runAPI(express, app, __dirname)
|
2022-07-08 18:17:56 +00: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 15:48:37 +00:00
|
|
|
}
|