cloudflare-client
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "cloudflare-client", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"packageManager": "yarn@4.0.0-rc.9", | ||
@@ -54,8 +54,23 @@ "description": "Universal HTTP client for Cloudflare API", | ||
"exports": { | ||
".": "./dist/index.js", | ||
"./user": "./dist/user.js", | ||
"./userTokens": "./dist/userTokens.js", | ||
"./dnsRecords": "./dist/dnsRecords.js", | ||
"./package.json": "./package.json" | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./user": { | ||
"types": "./dist/user.d.ts", | ||
"default": "./dist/user.js" | ||
}, | ||
"./userTokens": { | ||
"types": "./dist/userTokens.d.ts", | ||
"default": "./dist/userTokens.js" | ||
}, | ||
"./dnsRecords": { | ||
"types": "./dist/dnsRecords.d.ts", | ||
"default": "./dist/dnsRecords.js" | ||
}, | ||
"./package.json": { | ||
"default": "./package.json" | ||
} | ||
}, | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
@@ -62,0 +77,0 @@ "lint": "eslint --report-unused-disable-directives .", |
@@ -24,25 +24,33 @@ # Cloudflare API Client | ||
const settings = { zoneId: "xxx", accessToken: "<CLOUDFLARE_API_TOKEN>" }; | ||
// Get the currently logged in / authenticated user | ||
// https://api.cloudflare.com/#user-user-details | ||
await cf.user({ accessToken: "xxx" }).get(); | ||
await cf.user(settings).get(); | ||
// Verify the user's token | ||
// https://api.cloudflare.com/#user-api-tokens-verify-token | ||
await cf.userTokens({ accessToken: "xxx" }).verify(); | ||
await cf.userTokens(settings).verify(); | ||
// Get DNS Record details | ||
// https://api.cloudflare.com/#dns-records-for-a-zone-dns-record-details | ||
await cf.dnsRecords({ zoneId: "xxx", accessToken: "xxx" }).get("xxx"); | ||
await cf.dnsRecords(settings).get("xxx"); | ||
// Find a single DNS Record matching the search parameters | ||
// https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records | ||
await cf.dnsRecords({ zoneId: "xxx", accessToken: "xxx" }).find({ type: "A" }); | ||
await cf.dnsRecords(settings).find({ type: "A" }); | ||
// Get the list of DNS Records for the target zone | ||
// https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records | ||
await cf | ||
.dnsRecords({ zoneId: "xxx", accessToken: "xxx" }) | ||
.findMany({ type: "A" }); | ||
await cf.dnsRecords(settings).findMany({ type: "A" }); | ||
``` | ||
## Source Code | ||
For more information and usage examples check out the source code / tests: | ||
- **[`user.ts`](./src/user.ts)** ([tests](./src/user.test.ts)) | ||
- **[`userTokens.ts`](./src/userTokens.ts)** ([tests](./src/userTokens.test.ts)) | ||
- **[`dnsRecords.ts`](./src/dnsRecords.ts)** ([tests](./src/dnsRecords.test.ts)) | ||
## Backers 💰 | ||
@@ -49,0 +57,0 @@ |
18585
79