env.tsannotatedenv.tssource60 lines · 2.7 KB · raw

The Worker's bindings (wrangler.json). HUB exists only in --env dev: the MCP bridge is for developing songs locally, so a production deploy has no hub to reach and its MCP routes answer 404. The song list the votes check against comes from ASSETS (production and preview, which deploy the static build) or SONGS_URL (dev's Astro server); votes.ts takes whichever is there. DB is the site's D1 database, the same in both (its schema is worker/migrations/). EVENTS is the telemetry dataset (events.ts), CACHE the relay's answer cache (answer-cache.ts). BUDGET is one JevBudget object per signed-in user (budget.ts), charged JEV_DAILY_PER_USER relay calls a UTC day at most. LISTEN_LIMIT and RECORD_LIMIT are listening's (listening.ts). PARTY is the listening parties' rooms, one Durable Object each (party.ts), in both environments, and PARTY_LIMIT the per-visitor limit on joining one. COVERS is the R2 bucket of listener songs' cover images (content.ts); CONTENT_LIMIT and COVER_LIMIT are per author, BROWSE_LIMIT per visitor, for listeners' content. The hosted MCP (hosted-mcp.ts, everywhere, OAuth-protected by oauth.ts) keeps its clients, grants and tokens in OAUTH_KV, reaches a user's own tabs through TAB_HUB (one TabHub per account, tab-hub.ts), and is rate-limited per user by MCP_LIMIT. LOBBY is the site's one lobby (lobby.ts: who is listening to what), and LOBBY_LIMIT the per-visitor limit on joining it. PARTY_DIRECTORY is the site's one list of live parties (party-directory.ts), and DATA_LIMIT the per-visitor limit on reading what the site stores (data.ts).

24import type { JevBudget } from './budget';
25import type { Hub } from './hub';
26import type { LobbyRoom } from './lobby';
27import type { Party, PartyDirectory } from './party';
28import type { TabHub } from './tab-hub';
30type RateLimit = { limit(options: { key: string }): Promise<{ success: boolean }> };
31
32export interface Env {
33  JEVSTRUDEL_TYPESAFE_API_KEY?: string;
34  JEV_LIMIT: RateLimit;
35  VOTE_LIMIT: RateLimit;
36  AUTH_LIMIT: RateLimit;
37  LISTEN_LIMIT: RateLimit;
38  RECORD_LIMIT: RateLimit;
39  PARTY_LIMIT: RateLimit;
40  CONTENT_LIMIT: RateLimit;
41  COVER_LIMIT: RateLimit;
42  BROWSE_LIMIT: RateLimit;
43  MCP_LIMIT: RateLimit;
44  LOBBY_LIMIT: RateLimit;
45  DATA_LIMIT: RateLimit;
46  DB: D1Database;
47  EVENTS: AnalyticsEngineDataset;
48  CACHE: KVNamespace;
49  OAUTH_KV: KVNamespace;
50  COVERS: R2Bucket;
51  BUDGET: DurableObjectNamespace<JevBudget>;
52  JEV_DAILY_PER_USER: number | string;
53  HUB?: DurableObjectNamespace<Hub>;
54  PARTY: DurableObjectNamespace<Party>;
55  TAB_HUB: DurableObjectNamespace<TabHub>;
56  LOBBY: DurableObjectNamespace<LobbyRoom>;
57  PARTY_DIRECTORY: DurableObjectNamespace<PartyDirectory>;
58  ASSETS?: Fetcher;
59  SONGS_URL?: string;
60}