````md # outbound-guard
npm install @nextn/outbound-guard```mdoutbound-guard
A process-local Node.js library for safe outbound HTTP access.
It provides two independent tools, each solving a different real-world problem when calling external services:
---
For on-demand HTTP calls made by your application (APIs, BFFs, workers).
It protects your service when traffic spikes or upstreams misbehave by combining:
- request coalescing (duplicate GET collapse)
- bounded concurrency + queueing
- per-attempt timeouts
- a small health gate (OPEN → CLOSED → HALF_OPEN)
This is what you use when your code actively sends requests.
---
For continuously polling a single GET endpoint and serving its latest value instantly.
It runs in the background, fetches on a fixed interval, and lets your code read the most recent value with zero latency.
This is what you use when your code consumes external state.
---
These two features are independent but complementary.
---
| Feature | Purpose | Typical use |
|------|------|------|
| ResilientHttpClient | Protect outbound requests under load | APIs, gateways, webhook senders |
| InstantGetStore | Continuously poll & cache one GET endpoint | config flags, prices, health endpoints |
---
A guarded HTTP client that keeps your service predictable under pressure.
(Details below ⬇)
---
A lightweight background poller for a single GET URL.
returns instantly (no network call)
- Handles retry or stop behavior on failure
- Optionally waits until first successful fetch$3
- Remote config endpoints
- Feature flags
- Prices, rates, counters
- “Read often, update periodically” data(Details below ⬇)
---
---
Install
`bash
npm install @nextn/outbound-guard
``Node 18+ required (tested on Node 20).
---
Quick links
* Demos & usage examples
[https://github.com/next-n/guardtest]
---
─────────────────────────────
Resilient HTTP Client
─────────────────────────────
``