0.1.0 • Published 5 years ago

micro-ws v0.1.0

Weekly downloads
4
License
-
Repository
-
Last release
5 years ago

micro-ws

A parody of zeit/micro for WebSockets.

Example

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:

micro-ws server.js --listen tcp://0.0.0.0:3001

TODO

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.