diff --git a/api/src/cobalt.js b/api/src/cobalt.js index 473c9b5b..d3f21255 100644 --- a/api/src/cobalt.js +++ b/api/src/cobalt.js @@ -6,7 +6,7 @@ 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" +import { env } from "./modules/config.js" import path from 'path'; import { fileURLToPath } from 'url'; @@ -23,12 +23,9 @@ app.disable('x-powered-by'); await loadLoc(); -if (mode === 'API') { +if (env.apiURL) { const { runAPI } = await import('./core/api.js'); runAPI(express, app, gitCommit, gitBranch, __dirname) -} else if (mode === 'WEB') { - const { runWeb } = await import('./core/web.js'); - await runWeb(express, app, gitCommit, gitBranch, __dirname) } else { console.log( Red(`cobalt wasn't configured yet or configuration is invalid.\n`) diff --git a/api/src/modules/config.js b/api/src/modules/config.js index 662d8b05..4817931f 100644 --- a/api/src/modules/config.js +++ b/api/src/modules/config.js @@ -13,22 +13,18 @@ Object.values(servicesConfigJson.config).forEach(service => { ) }) -const - apiURL = process.env.API_URL || '', - - // WEB mode related environment variables - webEnvs = { - webPort: process.env.WEB_PORT || 9001, - webURL: process.env.WEB_URL || '', - showSponsors: !!process.env.SHOW_SPONSORS, - isBeta: !!process.env.IS_BETA, - plausibleHostname: process.env.PLAUSIBLE_HOSTNAME, - apiURL - }, - - // API mode related environment variables - apiEnvs = { - apiURL, +export const + services = servicesConfigJson.config, + hlsExceptions = servicesConfigJson.hlsExceptions, + audioIgnore = servicesConfigJson.audioIgnore, + version = packageJson.version, + genericUserAgent = config.genericUserAgent, + repo = packageJson.bugs.url.replace('/issues', ''), + ffmpegArgs = config.ffmpegArgs, + supportedAudio = config.supportedAudio, + links = config.links, + env = { + apiURL: process.env.API_URL || '', apiPort: process.env.API_PORT || 9000, apiName: process.env.API_NAME || 'unknown', @@ -52,21 +48,3 @@ const externalProxy: process.env.API_EXTERNAL_PROXY, } - -export const - services = servicesConfigJson.config, - hlsExceptions = servicesConfigJson.hlsExceptions, - audioIgnore = servicesConfigJson.audioIgnore, - version = packageJson.version, - genericUserAgent = config.genericUserAgent, - repo = packageJson.bugs.url.replace('/issues', ''), - authorInfo = config.authorInfo, - donations = config.donations, - ffmpegArgs = config.ffmpegArgs, - supportedAudio = config.supportedAudio, - celebrations = config.celebrations, - links = config.links, - sponsors = config.sponsors, - mode = (apiURL && !webEnvs.webURL) ? 'API' : - (webEnvs.webURL && apiURL) ? 'WEB' : undefined, - env = mode === 'API' ? apiEnvs : webEnvs \ No newline at end of file