$ show mollie/mollie-api-node
This repository is the official Mollie API client for Node.js (TypeScript), providing a typed SDK for integrating with the Mollie payment platform. It exposes a factory function `createMollieClient()` that returns an object with resource binders (e.g., `payments`, `orders`, `customers`, `refunds`, `settlements`), each offering CRUD operations and additional actions like cancellation or refunding. The architecture follows a clean layered design: resource-specific binders delegate to a shared `TransformingNetworkClient` that handles HTTP requests, response transformation, pagination, idempotency keys, retries, and throttling. Data models are separated into raw API interfaces and sealed helper-enriched types, with embedded/linked resource access abstracted through helper classes. The SDK supports both API key and OAuth authentication, callback-style and Promise-based APIs, and includes extensive test suites (unit, integration, and cross-runtime compatibility for Node, Bun, and Deno). The codebase is well-structured, uses modern TypeScript features, and includes a custom iteration API for paginated resources. Notable internal patterns include a generic Binder base class, parameter default injection, a throttling utility, and a rich set of type utilities (Maybe, Nullable, Seal, Xor).
The LLM identified 3 files worth highlighting for reuse:
A standalone throttling utility that limits the number of concurrent async operations. It uses a sliding window approach with a configurable limit and interval. The class is isolated (no internal imports) and can be extracted into any project needing rate-limited async execution. Demonstrates clean handling of concurrency control with a simple API (`throttle<T>(fn: () => Promise<T>): Promise<T>`).
Implements an async iterator that can be used with `for await...of` loops, wrapping page fetching and iteration with optional throttling and demand-sensing. It composes lower-level iteration helpers (DemandingIterator, LazyIterator) to support both manual sequential fetching and automatic pagination. This pattern is reusable for any paginated REST API and demonstrates a non-trivial approach to combining throttling, lazy loading, and infinite iteration in TypeScript.
A simple but valuable TypeScript type alias `Maybe<T> = T | null | undefined`. It is widely used throughout the codebase to express optional values. While trivial, its consistent use as a single source of truth for 'maybe missing' values improves type safety and readability. Can be reused in any TypeScript project.