API: add a typed hook for the /health/deep endpoint - #210
Open
greatest0fallt1me wants to merge 1 commit into
Open
API: add a typed hook for the /health/deep endpoint#210greatest0fallt1me wants to merge 1 commit into
greatest0fallt1me wants to merge 1 commit into
Conversation
useHealthDeep had no way to re-run the health check after the initial mount -- a caller that wanted to re-check after resolving a reported issue had no option but a full page reload. Add refetch(), matching the convention gap shared by the other data hooks in this repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note on scope
`useHealthDeep()` already existed and was already tested (fetch, typed result, success/error handling). The one real gap: no way to re-run the check after the initial mount.
Change
Added `refetch()` to `UseHealthDeepResult`, which re-triggers the fetch effect via an internal attempt counter. Loading/error state resets on each refetch.
Tests
Added a case: after an initial failed fetch, `refetch()` re-runs the request and recovers (loading toggles, second fetch call observed, health populated, error cleared).
`npx vitest run lib/hooks/useHealthDeep.test.ts`: 3 passed. `npx tsc --noEmit` / `npx eslint` on changed files: clean.
Closes #118