r/javascript • • Feb 14 '21

Why I Fell in Love with Cloudflare Workers

https://tobias-schneider.medium.com/why-i-fell-in-love-with-cloudflare-workers-8c2562aae246
0 Upvotes

15 comments sorted by

2

u/iamanenglishmuffin Feb 15 '21

I don't mind the topic but I wish the author was a bit more specific. This is all very high level and doesn't give me anything other than "no cold starts and cheaper". Is that it?

2

u/[deleted] Feb 15 '21 edited Feb 15 '21

Also way faster, but doesn't support node.js. If you're looking for a more specific example check out my GitHub: https://github.com/tsndr/cloudflare-worker-router There's also a specific guide in the works, so stay tuned for that.

2

u/paul_h Feb 15 '21

Hey Tobias, any chance of a hello-world github repo demoing the bits and pieces that's easy for the reader to try quickly?

2

u/[deleted] Feb 15 '21

Hey, there is an example on my github: https://github.com/tsndr/cloudflare-worker-router

2

u/paul_h Feb 15 '21

Nice work. People might do a note fine grained cors setup for themselves, right?

What other services from cloudflare have you had good experiences with. That you’d use from a severless function, I mean.

2

u/[deleted] Feb 15 '21

You can configure cors to your liking, I'm going to add this to my readme later today:

router.cors({
    allowOrigin: '*',
    allowMethods: '*',
    allowHeaders: '*',
    maxAge: 86400,
    optionsSuccessStatus: 204
})

The values set in this example are the default values.

I'm currently on the Workers Unbound Beta which extends the execution time up to 30 seconds. And I'm also trying out Pages Beta, which is a way to serverlessly host a frontend framework of your choosing (like React, Angular, Vue, Svelte and so on).

Just for clarification, I'm not affiliated with Cloudflare in any way, just a fan of their serverless solutions.

1

u/paul_h Feb 15 '21

Awesome. I didn’t think you were affiliated - for me your journey/rationale resonated. I was hoping you could talk up a cloudflare DB too. I guess we just blink and use something on AWS if needed.

1

u/[deleted] Feb 15 '21

For my project I used Workers KV, since I‘m not handling huge amounts of data and there‘s no need for complex database structures, although you could probably make it work using multiple KVs. If you‘re interested in a specific guide on that topic I‘m working on that as well. Feel free to follow my twitter to get notified once I post it @tsndr_

2

u/paul_h Feb 15 '21

Thanks. I'm now following you on Twitter. I'll read more about https://www.cloudflare.com/products/workers-kv/. It might be perfect for a kitchen-sink version of QLDB.

12

u/Lucidio Feb 15 '21

Holy keyword spamming. That article is written for Google algorithms in the early 2000s. Couldn't even finish it.

8

u/[deleted] Feb 15 '21

Why I became a shill for cloud flare workers

6

u/cgijoe_jhuckaby NaN Feb 15 '21

This article reads like an ad for Cloudflare. The author also links to them like 50 times.

1

u/jimmyco2008 Feb 15 '21

I don’t know the specific differences but Azure Functions might be an alternative. Pretty sure the NodeJS support is not “raw V8” though.

1

u/[deleted] Feb 15 '21

calls on $NET?