How vtempest/grab-api works
Main Components
A. Source Code (src/)
• Core module: grab-api.ts
• CLI Entrypoints: grab-cli.js, grab-url-cli.js
B. Build & Bundling (root)
• TypeScript (tsconfig.json) → compile to ES/CJS
• Vite (vite.config.js) for docs/live-reload
• Bun/Node for installs (bun.lock, package.json)
C. Distribution (dist/)
D. Documentation Pipeline
• create-api-docs/ → custom script to pull JSDoc/TypeDoc into OpenAPI/MDX
• docs-config/ (Docusaurus config + plugin output)
• docs/ (generated static site)
E. CI/CD (/.github/workflows/docs.yml)
• On push: compile code, build docs, deploy to GH Pages, publish to npm
F. Consumers & Runtime
• Browser & Node apps import from npm
• Global “grab” API on window/global
• fetch() under the hood to call external REST APIs
• Optional: mock server, dev-tools overlay, caching, retry, pagination
Relationships & Data Flows
• Source Code → (TypeScript compiler + Vite) → dist artifacts → npm registry
• Source Code + create-api-docs → docs-config → Docusaurus build → static docs → GitHub Pages
• CI triggers both build pipelines and publishes outputs
• Runtime consumer (web or Node) pulls package from npm, calls grab() → fetch → external API → back to UI
• Mock server: grab.mock intercepts → returns synthetic response
Architectural Patterns & Design Principles
• Plugin/Strategy: Consumers supply retry, pagination, mock, caching strategies via options
• Doc-as-Code: Automated extraction of API types into MDX/OpenAPI templates
• Single-function façade: “grab()” entrypoint for all features
• CI-driven release: workflows automatically build, test, document, and publish
Key Technologies & Frameworks
• TypeScript + tsc → static types, .d.ts outputs
• Vite → local dev server for docs, pre-bundle
• Bun/Node → dependency manager, test runner
• Docusaurus → static site generator for docs
• GitHub Actions → CI/CD for tests, docs deploy, npm publish
• fetch API → native HTTP requests
Elements
• Source → Build → Dist → npm registry → Consumer
• Source + Docs Generator → Docusaurus → GitHub Pages
• Consumer → grab() → fetch → External API
• Blue for source/build pipelines
• Green for runtime (consumer + external API)
• Orange for docs pipeline
• Purple for CI/CD
• Annotations: file paths (e.g. src/grab-api.ts, create-api-docs/, docs-config/) and technologies (TypeScript, Docusaurus, GitHub Actions)
Summary: