Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@webscopeio/react-health-check
Advanced tools
Lightweight React hook for checking health of API services.
Lightweight React hook for checking health of API services.
npm i @webscopeio/react-health-check
or
yarn add @webscopeio/react-health-check
const { available, refresh } = useHealthCheck({
service: {
name: 'auth',
url: 'https://example.com/auth/health',
},
onSuccess: ({ service, timestamp }) => {
console.log(`Service "${service.name}" is available since "${timestamp}" 🎉`);
},
onError: ({ service, timestamp }) => {
console.log(`Service "${service.name}" is not available since "${timestamp}" 😔`);
},
});
You can also create a global configuration so you don't have to define services and callbacks every time:
// App wrapper
<HealthCheckConfig
value={{
services: [
{
name: 'auth',
url: 'https://example.com/auth/health',
},
{
name: 'payment',
url: 'https://example.com/payment/health',
},
],
onSuccess: ({ service, timestamp }) => {
console.log(`Service "${service.name}" is available since "${timestamp}" 🎉`);
},
onError: ({ service, timestamp }) => {
console.log(`Service "${service.name}" is not available since "${timestamp}" 😔`);
},
}}
>
<App />
</HealthCheckConfig>;
// Later in some child component
const { available } = useHealthCheck('auth');
useHealthCheck()
hook accepts a configuration object with keys:
Key | Type | Description |
---|---|---|
service | Service<S = string> | Object defining an API service to be checked. |
onSuccess | (state: ServiceState<S>) => void; | Callback which should be called when API service becomes available again. |
onError | (state: ServiceState<S>) => void; | Callback which should be called when API service becomes unavailable. |
refreshInterval | number | Polling interval for health checks in milliseconds. Default value: 5000 |
refreshWhileHidden | boolean | Determines whether polling should be paused while browser window isn't visible. Default value: false |
Global configuration accepts the same keys as useHealthCheck()
hook with the exception of "service". You need to specify array of "services" when using global configuration.
MIT | Developed by Webscope.io
FAQs
Lightweight React hook for checking health of API services.
The npm package @webscopeio/react-health-check receives a total of 85 weekly downloads. As such, @webscopeio/react-health-check popularity was classified as not popular.
We found that @webscopeio/react-health-check demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.