Git Product home page Git Product logo

cloudflare-typescript's Issues

Wrong action name used when creating page rules

When a Forwarding URL page rule is created via the Dashboard and then retrieved via the API then the action id is forwarding_url. The TypeScript SDK requires this value to be forward_url. However, when `` is called with forward_url then the API returns an `HTTP 400` with a message `Unable to parse page rule`.

Change the SDK to use forwarding_url instead of forward_url.

Invalid typescript type when creating dns record of type NS

I am using 3.0.0-beta.3

I am trying to create a NS dns record.

When calling client.dns.records.create we are meant to pass in an object of type RecordCreateParams. According to the underlying API, this should be able to take a content attribute and a type attribute. Content will be the NS to point to. Type should be set to the value NS.

However, RecordCreateParams doesn't include a content attribute in the root (it's there buried in an attribute named data and if that's what I'm supposed to use then fine, but it doesn't seem like that's correct according to the underlying API or the code if I'm reading it right).

Also, RecordCreateParams has the type attribute hardcoded to URI. Am I thinking about this wrong? This seems like a bug in your type.

Here's my code and what I had to do. Note I have not yet run this code as I feared jacking things up not knowing if this cloudflare library is really a good idea or not or whether I need to fall back to just hitting the underlying APIs directly myself. Thanks for the attention.

await client.dns.records.create({
    zone_id: zoneId,
    name: fullDomanName,

    // The type for RecordCreateParams says this has to be URI but the API itself accepts NS
    type: 'NS',

    // The type for RecordCreateParams doesn't allow this but the API does
    content: nsName
} as unknown as RecordCreateParams);

Can't upload worker

Hi!, I'm trying to upload the Cloudflare Worker, and receiving this error:

2 | import { castToError } from "./core.mjs";
3 | export class CloudflareError extends Error {
4 | }
5 | export class APIError extends CloudflareError {
6 |     constructor(status, error, message, headers) {
7 |         super(`${APIError.makeMessage(status, error, message)}`);
                                    ^
error: 400 {"result":null,"success":false,"errors":[{"code":10021,"message":"could not read content for part metadata"}],"messages":[]}
      at new CloudflareError (:1:33)
      at new APIError (/home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/error.mjs:7:9)
      at new BadRequestError (/home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/error.mjs:85:9)
      at generate (/home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/error.mjs:36:20)
      at /home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/core.mjs:289:25

Steps to reproduce:

My current code, (the config is correct):

import Cloudflare, { toFile } from "cloudflare";
import { config } from "$app/config";

const cf = new Cloudflare({
    apiToken: config.cloudflare.apiToken
});

cf.workers.scripts.update("test-worker", {
    "<any part name>": [
        await toFile(Buffer.from(`export default {
            async fetch() {
                return new Response("Hello!");
            }
        }`), "index.js", {
            type: "application/javascript"
        })
    ],
    metadata: {
        bindings: [],
        main_module: "index.js",
    },
    account_id: config.cloudflare.accountId
})

Additional Information

Also, after reviewing the cloudflare code, I tried following:

cf.workers.scripts.update("test-worker", {
    "index.js": new File([`export default {
            async fetch() {
                return new Response("Hello!");
            }
        }`], "index.js", {
        type: "application/javascript"
    }),
    metadata: new File([JSON.stringify({
        bindings: [],
        main_module: "index.js",
    })], "metadata.json", {
        type: "application/json"
    }),
    account_id: config.cloudflare.accountId
})

Which occurs another error:

2 | import { castToError } from "./core.mjs";
3 | export class CloudflareError extends Error {
4 | }
5 | export class APIError extends CloudflareError {
6 |     constructor(status, error, message, headers) {
7 |         super(`${APIError.makeMessage(status, error, message)}`);
                                    ^
error: 400 {"result":null,"success":false,"errors":[{"code":10021,"message":"Uncaught TypeError: Main module must be an ES module.\n"}],"messages":[]}
      at new CloudflareError (:1:33)
      at new APIError (/home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/error.mjs:7:9)
      at new BadRequestError (/home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/error.mjs:85:9)
      at generate (/home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/error.mjs:36:20)
      at /home/mrbye/Documents/GitHub/flow-server/node_modules/cloudflare/core.mjs:289:25

Invalid format for X-Auth-Key header

I'm getting invalid format error with await cloudflare.accounts.list()

Error: 400 {"success":false,"errors":[{"code":6003,"message":"Invalid request headers","error_chain":[{"code":6103,"message":"Invalid format for X-Auth-Key header"}]}],"messages":[],"result":null}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.