mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 04:39:58 +00:00
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 { 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`)
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue