{"_id":"@alexcabezas0/circuit-breaker","name":"@alexcabezas0/circuit-breaker","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@alexcabezas0/circuit-breaker","version":"1.0.0","description":"A simple implementation of a CircuitBreaker to ensure a healthy status of your application","main":"./dist/CircuitBreaker.js","module":"./dist/CircuitBreaker.mjs","types":"./dist/CircuitBreaker.d.ts","scripts":{"build":"tsup"},"dependencies":{"node-cache":"^5.1.2"},"devDependencies":{"typescript":"^5.5.3","tsup":"^8.3.6"},"repository":{"type":"git","url":"git+https://github.com/alexcabezasg/ts-circuit-breaker.git"},"keywords":["circuit-breaker","npm","cb","typscript"],"author":{"name":"Alex Cabezas"},"license":"MIT","bugs":{"url":"https://github.com/alexcabezasg/ts-circuit-breaker/issues"},"homepage":"https://github.com/alexcabezasg/ts-circuit-breaker#readme","_id":"@alexcabezas0/circuit-breaker@1.0.0","gitHead":"e569d1c400cd353059a38fca454510c98670bdea","_nodeVersion":"22.13.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-hLLbPUFXkZ1S0bepblzteCa/SHxbzXciro/c7ctYvo7/Zx6uXESHkDxWB+t9lcxpx1twrIIWHd4miTbW4LKZhA==","shasum":"f2aeec7ad784aa482e9b5aca286cbf3fe72c4c23","tarball":"https://registry.npmjs.org/@alexcabezas0/circuit-breaker/-/circuit-breaker-1.0.0.tgz","fileCount":6,"unpackedSize":9192,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHuia/4/vO5FPEAa+/sze7JD+/z0md2U9qdF4FDEAme8AiEAjcFn+1G5BB2MILX3aFjj7OxROvg0/X3mGB3d888QZx4="}]},"_npmUser":{"name":"alexcabezas0","email":"alexcabezas0705@gmail.com"},"directories":{},"maintainers":[{"name":"alexcabezas0","email":"alexcabezas0705@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/circuit-breaker_1.0.0_1739120789361_0.40604732868153914"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-09T17:06:28.936Z","1.0.0":"2025-02-09T17:06:29.542Z","modified":"2025-02-09T17:06:29.832Z"},"maintainers":[{"name":"alexcabezas0","email":"alexcabezas0705@gmail.com"}],"description":"A simple implementation of a CircuitBreaker to ensure a healthy status of your application","homepage":"https://github.com/alexcabezasg/ts-circuit-breaker#readme","keywords":["circuit-breaker","npm","cb","typscript"],"repository":{"type":"git","url":"git+https://github.com/alexcabezasg/ts-circuit-breaker.git"},"author":{"name":"Alex Cabezas"},"bugs":{"url":"https://github.com/alexcabezasg/ts-circuit-breaker/issues"},"license":"MIT","readme":"# @alexcabezas0/circuit-breaker\n\n## Usage\n\n```typescript\nimport {CircuitBreaker, CircuitBreakerResponseStatus} from \"@alexcabezas0/circuit-breaker\";\n\nCircuitBreaker.installFuse(\"<FUSE_NAME>\", {\n    errors: 5, // Number of errors to tolerate before open the circuit\n    recovery_time_in_ms: 1000, // Number of ms that the circuit will be open\n    shouldMelt: (response) => response.status == 500 // Function to check if the circuit should melt\n})\n\nconst cb = CircuitBreaker.execute(\"<FUSE_NAME>\", () => httpclient.get());\nif (cb.status == CircuitBreakerResponseStatus.SUCCESS) {\n    res.json(cb.response) // actual data coming from downstream\n    // Procced\n} else {\n    // Return default, error, or whatever\n}\n```\n\n## Notes\n- The `fuse_name` represents the piece of code you want to protect (for example, a call to a store http client)\n- The circuit will melt as many times as errors are tolerated. After that, it will be open the amount of time described\nin the `recovery_time_in_ms`\n","readmeFilename":"README.md"}