A parody of zeit/micro for WebSockets.
npm install micro-wsA parody of zeit/micro for WebSockets.
``js
const { event, send } = require('micro-ws')
module.exports = async (conn) => {
const { name, data } = await event(conn)
if (name === 'hello') {
return send(conn, 'hello', { foo: 1 })
}
}
`
I've forked the command-line code from micro, so it is similar:
`sh`
micro-ws server.js --listen tcp://0.0.0.0:3001
I'm building this library to my needs in my projects, but I'm open to suggestions. Some ideas include:
- Hosting a joint HTTP + WS server (using micro for HTTP interface).
- Add more comprehensive functions for streamed messages.
- Explore alternatives to ws` for driving the WebSockets.