For better performance, consider replacing native Http with uws Http https://github.com/uNetworking/uWebSockets
Hey~! This is actually an optimization to make on the user-side, since no everyone can/will want to use UWS, unfortunately.
It's really easy to do actually, and works since the built-in http server isn't called unless you call start|listen on Polka directly. This means that you can create the uws server & pass in Polka's handler.
There's a full example coming to the repo soon~
const polka = require('polka');
const { http } = require('uws');
const { handler } = polka().use(...).get(...);
http.createServer(app.handler).listen(3000);
It's _a lot_ like the HTTPS example, which also passes the Polka handler into a custom server.
Closing because a UWS example is already on my todo list, and that's all Polka can support.
Hope that helps, thanks~!
@paulocoghi Think you deleted your comment, but I still got the email 馃槈
Yes you can still use middleware with uws http. Polka handles all routing & middleware; it only relies on http (or http replacement) to operate the request & response cycle.
Note that since this issue as closed, it's now possible to do this:
const polka = require('polka')
const { http } = require('uws');
let server = http.createServer(); // custom server
polka({ server }) // use SERVER directly
.use(middlware1, middleware2)
.get(...)
.listen(3000)
Thanks a lot, @lukeed :)
Most helpful comment
@paulocoghi Think you deleted your comment, but I still got the email 馃槈
Yes you can still use middleware with
uwshttp. Polka handles all routing & middleware; it only relies onhttp(orhttpreplacement) to operate the request & response cycle.Note that since this issue as closed, it's now possible to do this: