cobalt/api/src/modules/config.js

48 lines
1.8 KiB
JavaScript
Raw Normal View History

import UrlPattern from "url-pattern";
import { loadJSON } from "./sub/loadFromFs.js";
2024-05-12 15:06:04 +01:00
const config = loadJSON("./src/config.json");
const packageJson = loadJSON("./package.json");
const servicesConfigJson = loadJSON("./src/modules/processing/servicesConfig.json");
Object.values(servicesConfigJson.config).forEach(service => {
service.patterns = service.patterns.map(
pattern => new UrlPattern(pattern, {
segmentValueCharset: UrlPattern.defaultOptions.segmentValueCharset + '@\\.'
})
)
})
2024-08-02 16:32:00 +01:00
export const
services = servicesConfigJson.config,
hlsExceptions = servicesConfigJson.hlsExceptions,
audioIgnore = servicesConfigJson.audioIgnore,
version = packageJson.version,
genericUserAgent = config.genericUserAgent,
ffmpegArgs = config.ffmpegArgs,
supportedAudio = config.supportedAudio,
env = {
apiURL: process.env.API_URL || '',
apiPort: process.env.API_PORT || 9000,
listenAddress: process.env.API_LISTEN_ADDRESS,
freebindCIDR: process.platform === 'linux' && process.env.FREEBIND_CIDR,
corsWildcard: process.env.CORS_WILDCARD !== '0',
corsURL: process.env.CORS_URL,
cookiePath: process.env.COOKIE_PATH,
rateLimitWindow: (process.env.RATELIMIT_WINDOW && parseInt(process.env.RATELIMIT_WINDOW)) || 60,
rateLimitMax: (process.env.RATELIMIT_MAX && parseInt(process.env.RATELIMIT_MAX)) || 20,
durationLimit: (process.env.DURATION_LIMIT && parseInt(process.env.DURATION_LIMIT)) || 10800,
2024-05-16 16:00:11 +01:00
streamLifespan: 90,
2024-05-14 10:37:41 +01:00
processingPriority: process.platform !== 'win32'
&& process.env.PROCESSING_PRIORITY
2024-07-24 16:49:47 +01:00
&& parseInt(process.env.PROCESSING_PRIORITY),
externalProxy: process.env.API_EXTERNAL_PROXY,
}