$ show xDimGG/node-steamapi
This is a TypeScript library (v3.1.5) that wraps the Steam Web API, providing a clean, fully typed interface to interact with Steam's official and some undocumented endpoints. It is distributed as an ES module on npm under the name 'steamapi'. The library is architected around a single main class (`SteamAPI`) instantiated with an API key, which exposes methods for resolving Steam IDs, fetching game details, user profiles, achievements, badges, friends, bans, servers, and more. All API responses are parsed into strongly typed structure classes (e.g., `GameDetails`, `UserSummary`, `NewsPost`). It includes built-in configurable in-memory caching for game details and user resolution to reduce repeated API calls, and supports custom caching via a simple interface. The code is well-structured with clear separation of concerns between API logic, data models, and utility functions, and uses modern TypeScript features like interfaces, generics, and accessors. While it is not architecturally groundbreaking, it is a solid, professional-grade SDK that effectively encapsulates a complex external API with consistent error handling, caching strategies, and comprehensive type definitions. There are no significant reusable components that could be cleanly extracted to a new project, as the value lies in the integration with Steam's API, but the caching implementation and structure patterns provide a good reference for similar API wrapper projects.
The LLM identified 2 files worth highlighting for reuse:
An in-memory cache implementation with TTL (time-to-live) expiration. Defines a `CacheMap<K, V>` interface and provides a `MemoryCacheMap` class that internally uses a native `Map` with expiration timestamps. The `get` method automatically deletes expired entries. This component is self-contained (no imports beyond standard library), demonstrates clean encapsulation of a recurring caching pattern, and could be extracted into any TypeScript project requiring a simple TTL-backed cache with minimal modification.
A utility module that lazily loads the appropriate `fetch` implementation to support both modern Node.js (global `fetch`) and older environments via `node-fetch`. It exports a `lazyFetch` async function that first checks for global fetch and falls back to a dynamic import of `node-fetch`. This pattern solves a common cross-version compatibility issue in ESM Node.js packages and is reusable in any library that needs to abstract fetch without forcing a dependency on node-fetch when it's not needed.