I built upon this work from this repo to run yjs websockets in a serverless environment. I rewrote in typescript, and made it a tad easier to work with locally (after you deploy the db).
Try it here:
It uses AWS Lambda alongside DynamoDB to maintain socket connections.
A few unique things that I learned:
AWS Lambda supports only supports passing strings as responses. So we need to pass updates to the server and back as base64 strings, and not the standard binary type. This means the y-websocket client doesn’t work out of the box, you need to make a custom copy.
Handling Awareness? I wasn’t entirely clear on how to handle awareness data properly. Right now it just broadcasts the message. In an ideal world, it’s passed to clients as part of the initial document as well.
There was some feedback on the original repo for areas to improve. I tried to apply the updates on just the change vectors, and during updates, but I couldn’t really figure it out.
It does work, but I’m not sure what the right way is to test all of the test cases because it’s not perfect.
To make tweaks, the real work happens in this file in a series of three handlers for the sockets.