Postlight实验室 是我们的内部研讨会,我们在其中进行游戏,尝试工具和服务以及构建新应用。在这个新的Postlight 实验室项目中,高级工程师Shawn Kelly尝试使用Cloudflare 工作ers构建应用程序, and then published a starter kit for any engineer who wants to do the same.
Sometimes static files don’t cut it, but deploying a server 和 database can be too much if your app just needs a few features—stuff like rendering a page with dynamic data, manipulating headers, or handling authentication. I started this project with a 的ory: 云耀斑工人 might cover that middle ground between a full-featured server 和 a static client.
Proving 的 Theory
要了解新技术,我需要用它来构建一些东西。 秘密消息 is a demo app I built to give me a chance to poke around 的 云耀斑 platform. More specifically, I wanted to see if 工作ers could be used to deliver an app without an origin server.
从用户角度来看, 秘密消息 lets you write a message, encrypt it in 的 browser with a passphrase, 和 set an amount of time that message will expire in. It gives you a link you can share with 的 recipient of 的 message. Give it a try at //secretmsg.app.
秘密消息.app
Behind 的 scenes, 的 browser encrypts 的 message, 然后 sends it to 的 工作er which saves it in a 工人KV商店. To view 的 message, 的 recipient visits 的 associated link. The worker fetches 的 message from 的 store, renders 的 page, 和 sends 的 response. The recipient enters 的 passphrase to decrypt 的 message in 的 browser. You can explore 秘密消息’s source code here.
Overall, this particular stack is useful 对于 apps with a high read-to-write ratio. Especially with 工作ers KV, 的 more data is accessed, 的 more performance improves, which gives you dynamic content at static file speeds.
认识Cloudflare 工作er应用程序套件
Since this is a promising new technology that could be a great fit 对于 any large 的JavaScript project, I wanted to minimize setup 和 remove most of 的 learning curve 对于 other engineers to get started. From 秘密消息, I abstracted out 云耀斑 工作er应用套件, a handy set of tools 对于 creating, developing, testing, 和 deploying a 云耀斑 工作er app. No configuration, just build it 和 ship it.