fix: cache s3 client construction

⛔ closed · #143 · Open-Legal-Products/mike ← a1exxd0/mike · opened 2mo ago by a1exxd0 · closed 2mo ago · +14-9 across 1 file · ↗ on GitHub

From the PR description

Summary

Caching the S3 client in backend/src/lib/storage.ts.

What

Replaced getClient()'s new S3Client(...) call with module-level cached client.

Why

Previously, every uploadFile, downloadFile, deleteFile and getSignedUrl call constructed a new client. This is wasteful as config is static.

Testing

Local runs only. Not sure if this repo is missing tests at the time of writing, happy to be corrected. Also ran a Claude Code /security-review, no high-confidence issues.

Our analysis

Cache the S3 client instead of rebuilding it per call — read the full analysis →

Think the analysis missed something the PR description covers?

Capture this PR into my fork

Download a Markdown prompt that tells Claude how to port every commit in this PR into your working tree. Run it via claude -p < capture-pull-143.md from inside the repo you want the changes in.

⬇ Download capture-pull-143.md