mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
f150d40c45
Add an ATTACHMENTS_ENABLED switch (default on when R2 is bound) via a central getAttachmentBucket helper, surface R2 + estimated KV usage against the free tier on the status page and /api/stats (refreshed by the hourly cron), let setup.sh create and wire the R2 bucket, and bind the demo bucket so the deployed demo has attachments. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
10 lines
406 B
TypeScript
10 lines
406 B
TypeScript
import { Env } from "../types";
|
|
|
|
// Returns the attachment bucket only when the feature is enabled, so callers can
|
|
// narrow cleanly. Attachments are on whenever R2 is bound, unless explicitly
|
|
// turned off with ATTACHMENTS_ENABLED="false".
|
|
export function getAttachmentBucket(env: Env): R2Bucket | undefined {
|
|
if (env.ATTACHMENTS_ENABLED === "false") return undefined;
|
|
return env.ATTACHMENT_BUCKET;
|
|
}
|