From 6d38eea8f21cb80913d7d18200ca106a21db30df Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Thu, 22 Feb 2024 08:58:18 -0600 Subject: [PATCH] Config for blob upload limit (#2213) config var for blob upload limit --- packages/pds/src/config/config.ts | 4 +++- packages/pds/src/config/env.ts | 2 ++ packages/pds/src/index.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/pds/src/config/config.ts b/packages/pds/src/config/config.ts index e433f7ed251..8ca807d39b5 100644 --- a/packages/pds/src/config/config.ts +++ b/packages/pds/src/config/config.ts @@ -23,6 +23,7 @@ export const envToCfg = (env: ServerEnvironment): ServerConfig => { privacyPolicyUrl: env.privacyPolicyUrl, termsOfServiceUrl: env.termsOfServiceUrl, acceptingImports: env.acceptingImports ?? true, + blobUploadLimit: env.blobUploadLimit ?? 5 * 1024 * 1024, // 5mb } const dbLoc = (name: string) => { @@ -275,9 +276,10 @@ export type ServiceConfig = { publicUrl: string did: string version?: string - acceptingImports: boolean privacyPolicyUrl?: string termsOfServiceUrl?: string + acceptingImports: boolean + blobUploadLimit: number } export type DatabaseConfig = { diff --git a/packages/pds/src/config/env.ts b/packages/pds/src/config/env.ts index abe1904ad5f..fb5aed8232f 100644 --- a/packages/pds/src/config/env.ts +++ b/packages/pds/src/config/env.ts @@ -10,6 +10,7 @@ export const readEnv = (): ServerEnvironment => { privacyPolicyUrl: envStr('PDS_PRIVACY_POLICY_URL'), termsOfServiceUrl: envStr('PDS_TERMS_OF_SERVICE_URL'), acceptingImports: envBool('PDS_ACCEPTING_REPO_IMPORTS'), + blobUploadLimit: envInt('PDS_BLOB_UPLOAD_LIMIT'), // database dataDirectory: envStr('PDS_DATA_DIRECTORY'), @@ -116,6 +117,7 @@ export type ServerEnvironment = { privacyPolicyUrl?: string termsOfServiceUrl?: string acceptingImports?: boolean + blobUploadLimit?: number // database dataDirectory?: string diff --git a/packages/pds/src/index.ts b/packages/pds/src/index.ts index 77f5948e8aa..ea7c7aa53ee 100644 --- a/packages/pds/src/index.ts +++ b/packages/pds/src/index.ts @@ -63,7 +63,7 @@ export class PDS { payload: { jsonLimit: 100 * 1024, // 100kb textLimit: 100 * 1024, // 100kb - blobLimit: 5 * 1024 * 1024, // 5mb + blobLimit: cfg.service.blobUploadLimit, }, } if (cfg.rateLimits.enabled) {