Skip to main content

Function: makeFlatModule()

makeFlatModule(defs): Record<string, WrapperFn>

Defined in: leagues/_make_flat.ts:70

Build a league's non-ESPN "flat API" surface. For each flat wrapper, expose it under BOTH names (same fn), the same dual-case pattern as the ESPN wrappers:

  • mlb_teams(params) — snake_case (py/R parity),
  • mlbTeams(params) — camelCase canonical (idiomatic JS).

The wrapper resolves the request via resolveFlat, fetches the raw JSON, and — only when the caller passes { parsed: true } AND a parser is registered — runs the payload through the parser. Omitting parsed returns the raw JSON, so the dispatch is strictly additive (matches sdv-py's return_parsed=True).

Authenticated families (def.auth, e.g. nfl_api) additionally resolve a bearer-token header set before fetching: a caller-supplied params.headers is reused when present, else the family's AUTH_HEADER_PROVIDERS entry mints one (cached + auto-renewed). params.headers and params.parsed are control keys — resolveFlat only reads declared path/query params, so neither leaks into the query string.

Parameters

defs

WrapperDef[]

Flat WrapperDefs (those with flat: true for this api stem).

Returns

Record<string, WrapperFn>