feat: replace fixed 50-entry cap with size-based feed trimming

Emails are now trimmed from the oldest end when total serialised size
exceeds FEED_MAX_SIZE_BYTES (default 512 KB). Each EmailMetadata entry
stores its size so future trims are computed without re-reading KV.
Adds FEED_MAX_SIZE_BYTES, PROXY_TRUSTED_IPS and PROXY_AUTH_SECRET to Env.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Julien Herr
2026-05-21 08:26:09 +02:00
parent 984362f637
commit 9eba4c34c6
3 changed files with 78 additions and 4 deletions
+4
View File
@@ -3,6 +3,9 @@ export interface Env {
EMAIL_STORAGE: KVNamespace;
ADMIN_PASSWORD: string;
DOMAIN: string;
FEED_MAX_SIZE_BYTES?: string;
PROXY_TRUSTED_IPS?: string;
PROXY_AUTH_SECRET?: string;
}
// Email interface for stored emails
@@ -37,6 +40,7 @@ export interface EmailMetadata {
key: string;
subject: string;
receivedAt: number;
size?: number;
}
// Feed list interface