2023-12-09 11:00:54 +00:00
|
|
|
import UrlPattern from "url-pattern";
|
2023-10-12 12:33:26 +01:00
|
|
|
import { loadJSON } from "./sub/loadFromFs.js";
|
2024-05-12 15:06:04 +01:00
|
|
|
|
2023-10-12 12:33:26 +01:00
|
|
|
const config = loadJSON("./src/config.json");
|
|
|
|
const packageJson = loadJSON("./package.json");
|
|
|
|
const servicesConfigJson = loadJSON("./src/modules/processing/servicesConfig.json");
|
2022-07-17 12:08:49 +01:00
|
|
|
|
2023-12-09 11:00:54 +00:00
|
|
|
Object.values(servicesConfigJson.config).forEach(service => {
|
|
|
|
service.patterns = service.patterns.map(
|
|
|
|
pattern => new UrlPattern(pattern, {
|
2023-12-14 23:23:21 +00:00
|
|
|
segmentValueCharset: UrlPattern.defaultOptions.segmentValueCharset + '@\\.'
|
2023-12-09 11:00:54 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2024-04-29 12:56:05 +01:00
|
|
|
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 = {
|
2024-05-16 08:54:11 +01:00
|
|
|
apiURL,
|
2024-04-29 12:56:05 +01:00
|
|
|
apiPort: process.env.API_PORT || 9000,
|
|
|
|
apiName: process.env.API_NAME || 'unknown',
|
2024-05-16 08:54:11 +01:00
|
|
|
|
2024-05-13 19:20:10 +01:00
|
|
|
listenAddress: process.env.API_LISTEN_ADDRESS,
|
2024-05-16 08:54:11 +01:00
|
|
|
freebindCIDR: process.platform === 'linux' && process.env.FREEBIND_CIDR,
|
|
|
|
|
2024-04-29 12:56:05 +01:00
|
|
|
corsWildcard: process.env.CORS_WILDCARD !== '0',
|
|
|
|
corsURL: process.env.CORS_URL,
|
2024-05-16 08:54:11 +01:00
|
|
|
|
2024-04-29 12:56:05 +01:00
|
|
|
cookiePath: process.env.COOKIE_PATH,
|
2024-05-16 08:54:11 +01:00
|
|
|
|
|
|
|
rateLimitWindow: (process.env.RATELIMIT_WINDOW && parseInt(process.env.RATELIMIT_WINDOW)) || 60,
|
|
|
|
rateLimitMax: (process.env.RATELIMIT_MAX && parseInt(process.env.RATELIMIT_MAX)) || 20,
|
|
|
|
|
2024-05-16 15:57:48 +01:00
|
|
|
durationLimit: (process.env.DURATION_LIMIT && parseInt(process.env.DURATION_LIMIT)) || 10800,
|
2024-05-16 16:00:11 +01:00
|
|
|
streamLifespan: 90,
|
2024-05-16 15:57:48 +01:00
|
|
|
|
2024-05-14 10:37:41 +01:00
|
|
|
processingPriority: process.platform !== 'win32'
|
2024-05-14 10:20:58 +01:00
|
|
|
&& process.env.PROCESSING_PRIORITY
|
2024-05-16 08:54:11 +01:00
|
|
|
&& parseInt(process.env.PROCESSING_PRIORITY)
|
2024-04-29 12:56:05 +01:00
|
|
|
}
|
|
|
|
|
2022-07-17 12:08:49 +01:00
|
|
|
export const
|
2022-08-23 15:43:56 +01:00
|
|
|
services = servicesConfigJson.config,
|
2024-05-28 09:32:03 +01:00
|
|
|
hlsExceptions = servicesConfigJson.hlsExceptions,
|
2022-08-23 15:43:56 +01:00
|
|
|
audioIgnore = servicesConfigJson.audioIgnore,
|
2022-08-16 08:14:19 +01:00
|
|
|
version = packageJson.version,
|
|
|
|
genericUserAgent = config.genericUserAgent,
|
2024-05-14 10:37:41 +01:00
|
|
|
repo = packageJson.bugs.url.replace('/issues', ''),
|
2022-08-16 08:14:19 +01:00
|
|
|
authorInfo = config.authorInfo,
|
|
|
|
donations = config.donations,
|
|
|
|
ffmpegArgs = config.ffmpegArgs,
|
2022-10-27 17:27:20 +01:00
|
|
|
supportedAudio = config.supportedAudio,
|
2023-05-18 18:05:29 +01:00
|
|
|
celebrations = config.celebrations,
|
2023-10-12 12:33:26 +01:00
|
|
|
links = config.links,
|
2024-04-29 12:56:05 +01:00
|
|
|
sponsors = config.sponsors,
|
|
|
|
mode = (apiURL && !webEnvs.webURL) ? 'API' :
|
|
|
|
(webEnvs.webURL && apiURL) ? 'WEB' : undefined,
|
|
|
|
env = mode === 'API' ? apiEnvs : webEnvs
|