250 lines · 8.4 KB
import { env } from "cloudflare:workers";
import { validSitesDomain } from "./naming";

/** Bounds on what one deployment may collect from a branch folder or a workflow artifact. */
export const STATIC_LIMITS = {
  maxFiles: 5000,
  maxFileBytes: 25 * 1024 * 1024,
  maxTotalBytes: 512 * 1024 * 1024,
  maxArtifactBytes: 1024 * 1024 * 1024,
  uploadBatch: 100,
} as const;

/** One manifest file entry: git blob sha (the R2 content address) and size. */
export type ManifestFile = [sha: string, size: number];
export type Manifest = { files: Record<string, ManifestFile> };

/** Content-addressed deployment objects; the `pages/` prefix predates Sites and is kept so stored objects stay valid. */
export function objectKey(sha: string): string {
  return `pages/objects/${sha}`;
}

export const SITE_LIMITS = {
  cpuMs: 50,
  subRequests: 50,
  deploysPerSitePerHour: 30,
  previewsPerPush: 5,
  envEntries: 64,
  envValueBytes: 4096,
  historyLimit: 50,
  commitPreviewsPerPull: 5,
  sessionSeconds: 12 * 60 * 60,
} as const;

export const SCRATCH_LIMITS = {
  ttlMs: 24 * 60 * 60 * 1000,
  maxUploadBytes: 10 * 1024 * 1024,
  maxFiles: 500,
  maxTotalBytes: 10 * 1024 * 1024,
  perIpPerDay: 3,
  cpuMs: 10,