https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 11:50 AM
    I was just working on this yesterday evening. If you give me 5 mins, I'll be able to show you an example.
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 11:50 AM
    (I'm on mobile atm)
  • m

    macedonian

    01/11/2021, 11:51 AM
    Take all the time you need, really appreciate it!
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 12:12 PM
    Alright, so this is the small piece of documentation: https://developers.cloudflare.com/workers/platform/scripts#webassembly-module-bindings
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 12:18 PM
    In practice, an API call looks like this:
    Copy code
    PUT https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/scripts/$SCRIPT_NAME
    Authorization: Bearer $API_TOKEN
    Content-Type: multipart/form-data;boundary="boundary"
    
    --boundary
    Content-Disposition: form-data; name="script"; filename="script.js"
    
    addEventListener('fetch', (event) => event.respondWith(new Response("Hello, world!")))
    --boundary
    Content-Disposition: form-data; name="metadata"
    
    {"body_part": "script", "bindings": [{"type": "wasm_module", "name": "THE_BINDING_NAME_AVAILABLE_TO_THE_WORKER", "part": "wasm"}]}
    --boundary
    Content-Disposition: form-data; name="wasm"; filename="wasm_file.wasm"
    
    $WASM_CONTENT
    --boundary
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 12:19 PM
    Unfortunately I can't attach an image of what this looks like in a client like Insomnia.
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 12:23 PM
    Something like this in cURL:
    Copy code
    curl -X PUT -F wasm='@wasm_file.wasm' -F script='@script.js' -F metadata='{"body_part": "script", "bindings": [{"type": "wasm_module", "name": "THE_BINDING_NAME_AVAILABLE_TO_THE_WORKER", "part": "wasm"}]}' -H 'Authorization: Bearer $API_TOKEN' https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/scripts/$SCRIPT_NAME
  • m

    macedonian

    01/11/2021, 12:23 PM
    Thank you very much @User ! This seems pretty straightforward, I’m sure that I’ll manage with this information!
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 12:24 PM
    No problem! Like I said, I was just doing this the other day, so let me know if you run into any roadblocks.
  • m

    macedonian

    01/11/2021, 12:25 PM
    Will do!
  • t

    tijn

    01/11/2021, 1:51 PM
    Whats the best way to find freelance developers that know JS/Rust and CF Workers to hire them for a small project? Is there like a go to jobs site?
  • j

    Josh

    01/11/2021, 2:10 PM
    What are you trying to achieve? I'm sure some people here can give you some pointers, I don't think this is the place to hire people tho
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 3:08 PM
    I've just made a Feature request for wrangler to allow attaching pre-built WASM modules, @User . Would appreciate any other thoughts you might have. https://github.com/cloudflare/wrangler/issues/1716
  • m

    macedonian

    01/11/2021, 3:14 PM
    The feature request looks good to me. Although I most likely won’t ever use Wrangler. Right now I prefer to use the API directly, and once I’m going to production I’ll most likely use GitHub Actions to publish the Worker. I don’t know if the current GitHub Action support including WASM modules with the Worker.
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 3:17 PM
    If you haven't seen it before, there's an official wrangler GitHub action: https://github.com/cloudflare/wrangler-action. Just curious though, why the aversion to using wrangler in general? Any particular reason?
  • m

    macedonian

    01/11/2021, 3:22 PM
    I meant that I wouldn’t use Wrangler locally, but if I can use it using a GitHub action then I might use it. Although from experience I know that these tools usually don’t meet my (more advanced) requirements. I’m currently using Firebase and Azure and in both cases the CLI tools are not able to (properly) perform the actions I need and I end up using the API directly.
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2021, 3:23 PM
    Ah, fair enough. I realize this wasm thing is one example, but if you come across anything else that can't be done in wrangler that you need the API for, I'm sure everyone would love to hear about it, so we can try to make wrangler as useful as possible!
  • a

    adinetech.eth

    01/11/2021, 3:23 PM
    :0
  • m

    macedonian

    01/11/2021, 3:24 PM
    I’ll keep that in mind!
  • a

    adaptive

    01/11/2021, 3:33 PM
    What type of data are you using in KV?
  • m

    macedonian

    01/11/2021, 3:36 PM
    Most likely I’ll be using MessagePack, but if that doesn’t play nicely with Workers I might go for a different binary format.
  • d

    Deleted User

    01/11/2021, 4:45 PM
  • k

    kristian

    01/11/2021, 4:47 PM
    hey everyone, good morning 👋
  • f

    FlorianKoerner

    01/11/2021, 4:48 PM
    5.47pm in Germany. 😂 👍
  • j

    Josh

    01/11/2021, 4:49 PM
    Evening 👋
  • e

    eidam | SuperSaaS

    01/11/2021, 5:07 PM
    Evening 👋
  • a

    adaptive

    01/11/2021, 5:22 PM
    It's the processing time, does it make a difference to you to store in JSON or text?
  • m

    macedonian

    01/11/2021, 5:26 PM
    I did a test with JSON first, but the time it took to parse was too long. I might end up with a custom binary format to maximise performance.
  • k

    kristian

    01/11/2021, 8:01 PM
    hey friends - what has been the biggest struggle for you in building APIs on workers? i'm working on my next egghead course around serverless APIs and would love to hear about your pain points + what i could teach to new API developers 🙂
  • e

    eidam | SuperSaaS

    01/11/2021, 8:02 PM
    choosing the router 😅
1...404142...2509Latest