cloudflare-typescript  by cloudflare

Official TypeScript SDK for Cloudflare API

Created 2 years ago
711 stars

Top 47.8% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

Summary

This library offers a type-safe TypeScript interface for the Cloudflare REST API, targeting server-side developers. It simplifies API interactions, enhances productivity through strong typing, and provides convenient abstractions for common tasks.

How It Works

It acts as a direct wrapper around the Cloudflare API, generating TypeScript definitions for requests and responses. It supports various JavaScript runtimes, including Node.js, browsers, Deno, and Cloudflare Workers. Key features include built-in handling for file uploads, automatic retries, request timeouts, and seamless pagination, aiming to improve the developer experience.

Quick Start & Requirements

  • Installation: npm install cloudflare
  • Prerequisites: TypeScript >= 4.5. Supported runtimes: Web Browsers, Node.js (18 LTS+), Deno (v1.28.0+), Bun (1.0+), Cloudflare Workers, Vercel Edge Runtime, Jest (node env, 28+), Nitro (v2.6+).
  • Links: Cloudflare REST API docs: developers.cloudflare.com.

Highlighted Details

  • Type Safety: Comprehensive TypeScript definitions for API interactions.
  • File Uploads: Flexible support for various file input types (fs.ReadStream, File, fetch Response, toFile).
  • Error Handling: Specific APIError subclasses for distinct API issues (e.g., BadRequestError, AuthenticationError).
  • Retries & Timeouts: Default retry logic (2 retries) and 1-minute timeout, both configurable.
  • Auto-Pagination: Effortless iteration over paginated results via for await...of.
  • Advanced Access: Methods (.asResponse(), .withResponse()) for raw fetch response access; support for undocumented endpoints.
  • Customization: Options for custom fetch clients, HTTP(S) agents, and request/response handling.

Maintenance & Community

Actively maintained. Community engagement via bi-monthly triage meetings; urgent issues via Cloudflare support. Contribution guidelines available.

Licensing & Compatibility

  • License: Not explicitly stated in the provided README.
  • Compatibility: Broad runtime support, but explicitly not compatible with React Native or Jest's "jsdom" environment.

Limitations & Caveats

React Native and Jest's "jsdom" environment are unsupported. Internal tracking of many issues may limit community visibility for certain bug reports.

Health Check
Last Commit

17 hours ago

Responsiveness

Inactive

Pull Requests (30d)
17
Issues (30d)
2
Star History
34 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.