mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-03-11 17:45:38 +00:00
26 lines
779 B
TypeScript
26 lines
779 B
TypeScript
|
|
export const MAX_RESPONSE_SIZE = 10 * 1024 * 1024; // 10MB in bytes
|
|
|
|
/**
|
|
* Default axios request configuration with response size limits.
|
|
* Apply this to all axios.get() calls to prevent OOM crashes.
|
|
*/
|
|
export const safeAxiosConfig = {
|
|
maxContentLength: MAX_RESPONSE_SIZE,
|
|
maxBodyLength: MAX_RESPONSE_SIZE,
|
|
};
|
|
|
|
/**
|
|
* Creates a safe axios config with response size limits and optional timeout.
|
|
* @param timeout - Optional timeout in milliseconds (default: 10000)
|
|
* @param additionalConfig - Additional axios config to merge
|
|
* @returns Axios request config with safety limits
|
|
*/
|
|
export const createSafeAxiosConfig = (
|
|
timeout: number = 10000,
|
|
additionalConfig?: Record<string, any>
|
|
) => ({
|
|
...safeAxiosConfig,
|
|
timeout,
|
|
...additionalConfig,
|
|
});
|