Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace express-ws with something newer? #200

Closed
talentlessguy opened this issue May 10, 2021 · 5 comments
Closed

Replace express-ws with something newer? #200

talentlessguy opened this issue May 10, 2021 · 5 comments

Comments

@talentlessguy
Copy link

Hi,

sorry for writing here again, this is mroe like a suggestion rather than a question or bug report.

so, nollup uses express-ws. that library is ancient as hell (hasn't been updated for 3 years) and is full of unsolved issues.

see this thread: HenningM/express-ws#135

would it be better to replace express-ws with something newer?

@PepsRyuu
Copy link
Owner

Happy to change to it something else, open to suggestions on this one!

@talentlessguy
Copy link
Author

@PepsRyuu I'm currently working on a library similar to express-ws... expect a PR soon :D

(fyi this issue was created in case someone will suggest anything better than express-ws)

@talentlessguy
Copy link
Author

talentlessguy commented May 10, 2021

I propose tinyws as a replacement.

It's much smaller than express-ws, easier to use and comes with types out of the box (also doesn't depend on any framework but not that important here).

import express from 'express'

import { tinyws } from 'tinyws'

const app = express()

app.use('/', tinyws())

app.use('/hmr', async (req, res) => {
  if (req.ws) {
    const ws = await req.ws()

    return ws.send('hello there')
  } else {
    res.send('Hello from HTTP!')
  }
})

app.listen(3000)

@PepsRyuu
Copy link
Owner

Removed express-ws in 0.18.0 for plain ws.

@talentlessguy
Copy link
Author

@PepsRyuu amazing, thanks :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants