15 lines
691 B
TypeScript
15 lines
691 B
TypeScript
// General Blossom keeps its existing conservative default. The optional limit
|
|
// is explicit operator/package configuration, never an unauthenticated request.
|
|
export const DEFAULT_UPLOAD_BYTES = 16 * 1024 * 1024;
|
|
export const MAX_UPLOAD_BYTES = 2 * 1024 * 1024 * 1024;
|
|
|
|
export function uploadLimit(value: string | undefined): number {
|
|
if (value === undefined) return DEFAULT_UPLOAD_BYTES;
|
|
if (!/^[1-9][0-9]{0,9}$/.test(value)) throw new Error('Invalid ARCHY_BLOSSOM_MAX_UPLOAD_BYTES');
|
|
const limit = Number(value);
|
|
if (!Number.isSafeInteger(limit) || limit > MAX_UPLOAD_BYTES) {
|
|
throw new Error('ARCHY_BLOSSOM_MAX_UPLOAD_BYTES exceeds supported maximum');
|
|
}
|
|
return limit;
|
|
}
|