Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/colyseus/uwebsockets-express
Express API compatibility layer for uWebSockets.js
https://github.com/colyseus/uwebsockets-express
express expressjs nodejs uwebsockets uwebsocketsjs websockets
Last synced: 5 days ago
JSON representation
Express API compatibility layer for uWebSockets.js
- Host: GitHub
- URL: https://github.com/colyseus/uwebsockets-express
- Owner: colyseus
- License: mit
- Created: 2021-06-21T21:20:45.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T13:20:15.000Z (3 months ago)
- Last Synced: 2024-11-04T03:16:31.370Z (10 days ago)
- Topics: express, expressjs, nodejs, uwebsockets, uwebsocketsjs, websockets
- Language: TypeScript
- Homepage: https://npmjs.com/package/uwebsockets-express
- Size: 175 KB
- Stars: 57
- Watchers: 5
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uWebSockets.js + Express
Express API compatibility layer for uWebSockets.js.
## Usage
```typescript
import uWS from "uWebSockets.js"
import expressify from "uwebsockets-express"const uwsApp = uWS.App();
const app = expressify(uwsApp);// use existing middleware implementations!
app.use(express.json());
app.use('/', serveIndex(path.join(__dirname, ".."), { icons: true, hidden: true }))
app.use('/', express.static(path.join(__dirname, "..")));// register routes
app.get("/hello", (req, res) => {
res.json({ hello: "world!" });
});app.listen(8000);
```## Compatibility coverage
- ✅ Middleware support
- ✅ Supports existing Express Router instances
- Response API
- ✅ res.headersSent
- ✅ res.locals
- ✅ res.append()
- ✅ res.clearCookie()
- ✅ res.cookie()
- ✅ res.end()
- ✅ res.get()
- ✅ res.json()
- ✅ res.jsonp()
- ✅ res.location()
- ✅ res.redirect()
- ✅ res.render()
- ✅ res.send()
- ✅ res.sendFile()
- ✅ res.sendStatus()
- ✅ res.set()
- ✅ res.status()
- ✅ res.type()
- ✅ res.vary()
- ❌ res.app
- ❌ res.attachment()
- ❌ res.download()
- ❌ res.format()
- ❌ res.links()
- Request API
- ✅ req.baseUrl
- ✅ req.body
- ✅ req.ip
- ✅ req.method
- ✅ req.originalUrl
- ✅ req.params
- ✅ req.path
- ✅ req.query
- ✅ req.accepts()
- ✅ req.get()
- ✅ req.param()
- ❌ req.app
- ❌ req.cookies
- ❌ req.fresh
- ❌ req.hostname
- ❌ req.ips
- ❌ req.protocol
- ❌ req.route
- ❌ req.secure
- ❌ req.signedCookies
- ❌ req.stale
- ❌ req.subdomains
- ❌ req.xhr
- ❌ req.acceptsCharsets()
- ❌ req.acceptsEncodings()
- ❌ req.acceptsLanguages()
- ❌ req.is()
- ❌ req.range()
- ❌ req.pipe()## Middleware support
- ✅ [express/session](https://github.com/expressjs/session)
- ✅ [express/serve-index](https://github.com/expressjs/serve-index)
- ✅ [express/serve-static](https://github.com/expressjs/serve-static) (`express.static()`)## Disclaimer
Having an express compatibility layer on top of uWS is going to bring its performance slightly down. This library does not have performance as its only objective.
If you find potential improvements to make it more performant, feel free to send me a pull-request!
## License
MIT