Repository navigation
Expand file tree
/
Copy pathmlbConfig.ts
More file actions
66 lines (60 loc) · 1.81 KB
/
Copy pathmlbConfig.ts
File metadata and controls
66 lines (60 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Central config for the real MLB Stats API integration.
*
* The MLB Stats API is public, key-less, and pull-based (refreshes ~every 12s).
* All cadence/URL knobs live here so etiquette is tuned in one place; the
* GUMBO -> types mapping lives in `mlbAdapter.ts`.
*/
export const MLB_BASE = "https://statsapi.mlb.com";
/**
* DiamondAI inference server (the real trained model). Called SERVER-SIDE from the
* game route / adapter; falls back to the sim.ts stub when unreachable.
*/
// `.replace` strips any trailing slash so a Vercel value like
// "https://…hf.space/" can't produce a double-slash 404 on `${INFERENCE_URL}/health`.
export const INFERENCE_URL = (process.env.INFERENCE_URL ?? "http://localhost:8000").replace(/\/+$/, "");
/** The model needs a short pitch history; earlier pitches use the stub fallback. */
export const MODEL_WINDOW = 7;
/** Server-side cache windows (seconds) for the upstream MLB fetches. */
export const SCHEDULE_REVALIDATE = 15;
export const GAME_REVALIDATE = 10;
/** Client poll cadence (ms). Never poll faster than ~10s; live games only. */
export const SCHEDULE_POLL_MS = 15_000;
export const LIVE_GAME_POLL_MS = 12_000;
/**
* MLB numeric team id -> our internal short id (the keys of `TEAMS` in
* `teams.ts`). Mapping by id is stable across the API's abbreviation quirks
* (e.g. AZ vs our `ari`, ATH vs our `oak`).
*/
export const MLB_TEAM_ID: Record<number, string> = {
108: "laa",
109: "ari",
110: "bal",
111: "bos",
112: "chc",
113: "cin",
114: "cle",
115: "col",
116: "det",
117: "hou",
118: "kc",
119: "lad",
120: "wsh",
121: "nym",
133: "oak",
134: "pit",
135: "sd",
136: "sea",
137: "sf",
138: "stl",
139: "tb",
140: "tex",
141: "tor",
142: "min",
143: "phi",
144: "atl",
145: "cws",
146: "mia",
147: "nyy",
158: "mil",
};