apiboot
v1.0.1
Published
Zero-dependency HTTP client with a Koa-style middleware pipeline: compose auth, logging, retries around fetch.
Maintainers
Readme
apiboot
A zero-dependency HTTP client with a Koa-style middleware pipeline. Compose auth-header injection, logging, retries, and error handling around fetch — without pulling in a heavy HTTP library.
Pricing
Free. MIT-licensed, open source. No fees, no tiers.
Install
npm install apibootUsage
const { createClient, authBearer, logger, retry } = require("apiboot");
const api = createClient({ baseUrl: "https://api.example.com", timeout: 8000 });
// Compose middleware (runs in order: logger -> auth -> retry -> request)
api
.use(logger(console.log))
.use(authBearer(process.env.API_TOKEN))
.use(retry({ retries: 2, delay: 300 }));
// Requests now flow through the pipeline
const users = await api.get("/users", { params: { page: 2 } });
const created = await api.post("/users", { name: "Ada" });
await api.patch("/users/1", { role: "admin" });
await api.delete("/users/1");Write your own middleware
api.use(async (ctx, next) => {
ctx.headers["X-Request-Id"] = crypto.randomUUID();
await next(); // proceed downstream
// ctx.res, ctx.data are now populated
});API
createClient({ baseUrl, timeout, fetchFn })→{ use, get, post, put, patch, delete }authBearer(token)→ middlewarelogger(log?)→ middlewareretry({ retries, delay })→ middleware (retries network errors & 5xx)
License
MIT © shinnjr
