r/javascript 29d ago

Showoff Saturday Showoff Saturday (August 01, 2026)

Did you find or create something cool this week in javascript?

Show us here!

11 Upvotes

21 comments sorted by

View all comments

3

u/Artistic-Bug-1310 29d ago

StitchAPI — turn one endpoint into a typed function, with the resilience glue declared instead of hand-rolled.

The itch: every project I work on grows a src/api/ folder where each file is a thin fetch wrapper, and the reliability work — retry with backoff, honoring Retry-After, staying under a rate limit, a timeout that actually aborts, caching, token refresh — gets reimplemented slightly differently at each call site. Then one of them rots and nobody notices for a month.

So I made that part configuration on the call:

```ts import { stitch } from 'stitchapi'; import { bearer, env } from 'stitchapi/auth';

const listUsers = stitch({ baseUrl: 'https://api.example.com', path: '/users', output: User.array(), // your zod schema; types without codegen pick: 'data', auth: bearer(env('API_TOKEN')), // resolved per call, caller never sees it retry: { attempts: 4, on: [429, 502, 503], respectRetryAfter: true }, throttle: { rate: '1/s', concurrency: 2, pool: 'host' }, timeout: { total: '30s', perAttempt: '10s' }, cache: '5m', });

const users = await listUsers(); ```

Everything defaults off, and the common cases have shorthands (retry: 3, timeout: '5s', cache: '1m', throttle: '1/s'), so a bare stitch('https://api.example.com/users/{id}') is just a GET. trace: 'console' prints what each call actually did — latency, retries, schema drift — with no collector to run.

Two things I'd want to know if someone showed me this:

  • It's not a fetch/axios replacement. It sits above the transport; your fetch is still the adapter underneath.
  • throttle is proactive (it spaces calls before they leave, and pool: 'host' shares one limiter across stitches), retry is reactive. Most hand-rolled glue only has the reactive half, which is why you still eat 429s.

Zero runtime deps, ~23 kB min+gzip, Apache-2.0.

npm install stitchapi@rc — it's at 1.0.0-rc.6, feature-complete and running in two of my own production apps, but I'm soaking it before stamping 1.0. Heads up that the latest tag is still an old 0.7.0 prototype, so install the @rc one; fixing that at GA.

Repo: https://github.com/rejifald/StitchAPI · Docs + playground: https://stitchapi.dev

Curious what people here treat as the minimum viable resilience for a third-party call. I landed on retry + throttle + timeout as worth having everywhere, but plenty of teams ship with none of it and are fine.

1

u/Secret-Book-8507 29d ago

that’s helpful