An opinionated wrapper for Cloudflare's v4 API.
This package provides an basic interface to interact with Cloudflare's API, with built-in functionality like error handling, retries, and pagination handling.
To add this package to your project, simply run:
npm install @nephelaiio/cloudflare-api
import { api } from '@nephelaiio/cloudflare-api';
const options = {
token: 'YOUR_CLOUDFLARE_TOKEN',
path: '/zones'
};
async function fetchZones() {
const data = await api(options);
console.log(data);
}
fetchZones();
token
: Your Cloudflare API token.path
: The API endpoint path.method
: HTTP method (GET
,POST
,PUT
,PATCH
,DELETE
,HEAD
).body
: Request body, if any.ignore_errors
: An array of HTTP status codes that should not be treated as errors.
This package has a dependency on @nephelaiio/logger
for logging purposes.
For bug reports, please open an issue on GitHub.
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.
Ensure your code adheres to our linting and test guidelines:
make lint
make test
- Use OpenAPI Typescript fetch generator along with Cloudflare's OpenAPI schemas to auto-generate complete type aware interface to v4 API
This project is licensed under the MIT License - see the LICENSE file for details.