Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.84 KB

File metadata and controls

42 lines (30 loc) · 1.84 KB

@languages-learner/api

Generated API contract and the typed SDK that apps/web uses to talk to apps/backend.

Links

Contents

Path What it is
src/schemas/ openapi.json + api.tsgenerated, never edit by hand
src/sdk/ Hand-written wrapper over the generated types (createSdk, createApiClient)
src/database.types* Generated Supabase database types
src/types.ts Shared response shapes (ApiError, PaginatedResponse)
src/utils/ getErrorMessage

createSdk(supabase, options) attaches the caller's Supabase access token to every request. It defaults to a relative /api base URL, which only resolves in the browser — server-side callers (SSR) must pass an absolute baseUrl, see ApiClientOptions.

Regenerating

Both generated layers are produced from apps/backend, not from this package:

pnpm --filter app-backend generate:api-schemas   # DTOs → openapi.json → api.ts
pnpm --filter app-backend generate-types         # Supabase → database.types.ts

See apps/backend/README.md for the full contract chain. Commit the regenerated files together with the backend change — otherwise apps/web typechecks against a stale contract.

Scripts

pnpm --filter @languages-learner/api lint
pnpm --filter @languages-learner/api typecheck