How do you set up a Websocket server as a Cloudflare Worker?


I am trying to set up an extremely simple Websocket server as a Cloudflare Worker, but it seems impossible to find easy-to-follow instructions on the topic.

Cloudflare has this Websocket Template repository but it contains zero instructions and the accompanying blog post doesn’t actually tell you anything about how to use it:

I opened up Workers Playground and pasted in the two .js files from the template repository. It gives an error:

This whole process is extremely frustrating. I can’t believe Cloudflare doesn’t have better documentation or a tutorial for what should be a very simple process.