api: remove web mode & variables
This commit is contained in:
parent
eede972ace
commit
2575b0c145
2 changed files with 14 additions and 39 deletions
|
@ -6,7 +6,7 @@ import express from "express";
|
||||||
import { Bright, Green, Red } from "./modules/sub/consoleText.js";
|
import { Bright, Green, Red } from "./modules/sub/consoleText.js";
|
||||||
import { getCurrentBranch, shortCommit } from "./modules/sub/currentCommit.js";
|
import { getCurrentBranch, shortCommit } from "./modules/sub/currentCommit.js";
|
||||||
import { loadLoc } from "./localization/manager.js";
|
import { loadLoc } from "./localization/manager.js";
|
||||||
import { mode } from "./modules/config.js"
|
import { env } from "./modules/config.js"
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
@ -23,12 +23,9 @@ app.disable('x-powered-by');
|
||||||
|
|
||||||
await loadLoc();
|
await loadLoc();
|
||||||
|
|
||||||
if (mode === 'API') {
|
if (env.apiURL) {
|
||||||
const { runAPI } = await import('./core/api.js');
|
const { runAPI } = await import('./core/api.js');
|
||||||
runAPI(express, app, gitCommit, gitBranch, __dirname)
|
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 {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
Red(`cobalt wasn't configured yet or configuration is invalid.\n`)
|
Red(`cobalt wasn't configured yet or configuration is invalid.\n`)
|
||||||
|
|
|
@ -13,22 +13,18 @@ Object.values(servicesConfigJson.config).forEach(service => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const
|
export const
|
||||||
apiURL = process.env.API_URL || '',
|
services = servicesConfigJson.config,
|
||||||
|
hlsExceptions = servicesConfigJson.hlsExceptions,
|
||||||
// WEB mode related environment variables
|
audioIgnore = servicesConfigJson.audioIgnore,
|
||||||
webEnvs = {
|
version = packageJson.version,
|
||||||
webPort: process.env.WEB_PORT || 9001,
|
genericUserAgent = config.genericUserAgent,
|
||||||
webURL: process.env.WEB_URL || '',
|
repo = packageJson.bugs.url.replace('/issues', ''),
|
||||||
showSponsors: !!process.env.SHOW_SPONSORS,
|
ffmpegArgs = config.ffmpegArgs,
|
||||||
isBeta: !!process.env.IS_BETA,
|
supportedAudio = config.supportedAudio,
|
||||||
plausibleHostname: process.env.PLAUSIBLE_HOSTNAME,
|
links = config.links,
|
||||||
apiURL
|
env = {
|
||||||
},
|
apiURL: process.env.API_URL || '',
|
||||||
|
|
||||||
// API mode related environment variables
|
|
||||||
apiEnvs = {
|
|
||||||
apiURL,
|
|
||||||
apiPort: process.env.API_PORT || 9000,
|
apiPort: process.env.API_PORT || 9000,
|
||||||
apiName: process.env.API_NAME || 'unknown',
|
apiName: process.env.API_NAME || 'unknown',
|
||||||
|
|
||||||
|
@ -52,21 +48,3 @@ const
|
||||||
|
|
||||||
externalProxy: process.env.API_EXTERNAL_PROXY,
|
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
|
|
Loading…
Reference in a new issue