cloudflare-bread
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

cloudflare-bread

JavaScript fetch API client for Cloudflare's API with TypeScript definitions generated from the new Cloudflare's OpenAPI schema.

Project status

Alpha: being used in certain non-critical applications

Usage

Install with your package manager of choice:

npm install cloudflare-bread

# or...

yarn add cloudflare-bread

# or...

pnpm install cloudflare-bread

Use the API and get type definitions:

import { createClient } from 'cloudflare-bread'

const client = createClient({ token: process.env.CLOUDFLARE_API_TOKEN })

const response = await client.zones.zoneIdentifier('example.com').dns_records.$get({
  searchParams: {
    type: 'CNAME'
  }
})

if (response.status === 200) {
  const results = await response.json()
  //    ^? this will be typed
}

TODO

  • [ ] Collapse different params on the same position into a single one.
  • [ ] Fix searchParams being required even tho none of the params are actually required
  • [ ] Improve types of middleware

License

MIT, see LICENSE

Package Sidebar

Install

npm i cloudflare-bread

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

3.1 MB

Total Files

9

Last publish

Collaborators

  • stefanmaric