mirror of
https://github.com/imputnet/cobalt.git
synced 2025-12-16 04:58:53 +00:00
refactor: centralize envs and their defaults in modules/config (#464)
* feat(config): centralized env variables and their default values * fix: fip `corsWildcard` variable check in `corsConfig` * fix(config): use already declared variables and default some strings to undefined * fix: check processingPriority against NaN
This commit is contained in:
@@ -3,7 +3,7 @@ import { randomBytes } from "crypto";
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
import { decryptStream, encryptStream, generateHmac } from "../sub/crypto.js";
|
||||
import { streamLifespan } from "../config.js";
|
||||
import { streamLifespan, env } from "../config.js";
|
||||
import { strict as assert } from "assert";
|
||||
|
||||
const M3U_SERVICES = ['dailymotion', 'vimeo', 'rutube'];
|
||||
@@ -54,7 +54,7 @@ export function createStream(obj) {
|
||||
encryptStream(streamData, iv, secret)
|
||||
)
|
||||
|
||||
let streamLink = new URL('/api/stream', process.env.API_URL);
|
||||
let streamLink = new URL('/api/stream', env.apiURL);
|
||||
|
||||
const params = {
|
||||
't': streamID,
|
||||
@@ -85,7 +85,7 @@ export function createInternalStream(url, obj = {}) {
|
||||
controller: new AbortController()
|
||||
};
|
||||
|
||||
let streamLink = new URL('/api/istream', `http://127.0.0.1:${process.env.API_PORT || 9000}`);
|
||||
let streamLink = new URL('/api/istream', `http://127.0.0.1:${env.apiPort}`);
|
||||
streamLink.searchParams.set('t', streamID);
|
||||
return streamLink.toString();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { create as contentDisposition } from "content-disposition-header";
|
||||
|
||||
import { metadataManager } from "../sub/utils.js";
|
||||
import { destroyInternalStream } from "./manage.js";
|
||||
import { ffmpegArgs } from "../config.js";
|
||||
import { env, ffmpegArgs } from "../config.js";
|
||||
import { getHeaders } from "./shared.js";
|
||||
|
||||
function toRawHeaders(headers) {
|
||||
@@ -44,8 +44,8 @@ function pipe(from, to, done) {
|
||||
}
|
||||
|
||||
function getCommand(args) {
|
||||
if (process.env.PROCESSING_PRIORITY && process.platform !== "win32") {
|
||||
return ['nice', ['-n', process.env.PROCESSING_PRIORITY, ffmpeg, ...args]]
|
||||
if (!isNaN(env.processingPriority) && process.platform !== "win32") {
|
||||
return ['nice', ['-n', env.processingPriority.toString(), ffmpeg, ...args]]
|
||||
}
|
||||
return [ffmpeg, args]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user