Document the apiClient request contract and auth-error handler registration
Description
src/lib/apiClient.ts exposes apiGet/apiPost/apiPatch/apiDelete, an ApiError shape, 204/empty-body handling, and a single-slot registerAuthErrorHandler consumed by src/components/ApiAuthGuard.tsx. None of this is documented, so contributors don't know how errors surface or that only one auth handler can be registered at a time. This issue documents the module's contract.
Requirements and context
- Repository scope: StableRoute-Org/Stableroute-frontend only.
- Describe each helper, the
ApiError envelope (error, message, requestId), how thrown errors carry status, and the 204/empty-text path.
- Document the auth-error handler lifecycle: single slot, returned unregister function, and that
<ApiAuthGuard> wires it to toasts.
- Add
///-style JSDoc to the exported functions to match the in-file style.
Suggested execution
- Fork the repo and create a branch
git checkout -b docs/api-client-contract
- Implement changes
- Write code in: JSDoc additions in
src/lib/apiClient.ts (comments only).
- Write comprehensive tests in: not applicable for docs; ensure existing
src/lib/__tests__/apiClient.test.ts still passes.
- Add documentation: an "API client" section in
README.md covering helpers, error shape, and the auth handler.
- Validate accessibility: not applicable.
- Test and commit
Test and commit
- Run
npm run lint, npm test, and npm run build.
Example commit message
docs: document apiClient request contract and auth-error handler
Guidelines
- Minimum 95 percent test coverage for impacted modules.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
- ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.
Document the apiClient request contract and auth-error handler registration
Description
src/lib/apiClient.tsexposesapiGet/apiPost/apiPatch/apiDelete, anApiErrorshape, 204/empty-body handling, and a single-slotregisterAuthErrorHandlerconsumed bysrc/components/ApiAuthGuard.tsx. None of this is documented, so contributors don't know how errors surface or that only one auth handler can be registered at a time. This issue documents the module's contract.Requirements and context
ApiErrorenvelope (error,message,requestId), how thrown errors carrystatus, and the 204/empty-text path.<ApiAuthGuard>wires it to toasts.///-style JSDoc to the exported functions to match the in-file style.Suggested execution
git checkout -b docs/api-client-contractsrc/lib/apiClient.ts(comments only).src/lib/__tests__/apiClient.test.tsstill passes.README.mdcovering helpers, error shape, and the auth handler.Test and commit
npm run lint,npm test, andnpm run build.Example commit message
docs: document apiClient request contract and auth-error handlerGuidelines
Community & contribution rewards