From 32be713954bfdd7db3f039d2dd83f4b5a8e562fa Mon Sep 17 00:00:00 2001 From: Johnathon Weaver Date: Sun, 13 Aug 2023 01:01:22 +0800 Subject: [PATCH 1/2] Update socketio.md Add a basic explanation for uWS. --- docs/api/socketio.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/api/socketio.md b/docs/api/socketio.md index 0f363c194c..e268be74d6 100644 --- a/docs/api/socketio.md +++ b/docs/api/socketio.md @@ -82,6 +82,34 @@ Try to avoid listening and sending events on the `socket` directly since it circ +#### Using uWebSockets.js + +uWS can be used as a drop in replacement for socket handling. +As a result you'll see lower latencies, a better memory footprint and even slightly less overall resource usage. +You will on the other hand need to install the following extra package to get things working. + +``` +npm install uNetworking/uWebSockets.js#20.31.0 --save +``` + +Now you can use the `io.attachApp` function to attach uWS as a replacement. + +```ts +import { feathers } from '@feathersjs/feathers' +import socketio from '@feathersjs/socketio' +import { App } from 'uWebSockets.js' + +const app = feathers() + +app.configure( + socketio((io) => { + io.attachApp(App()) + }) +) + +app.listen(3030) +``` + ### socketio(options [, callback]) `app.configure(socketio(options [, callback]))` sets up the Socket.io transport with the given [Socket.io options object](https://github.com/socketio/engine.io#methods-1) and optionally calls the callback described above. From 3306bef853c1443447bd05125b497713bee0a294 Mon Sep 17 00:00:00 2001 From: Johnathon Weaver Date: Tue, 15 Aug 2023 13:07:25 +0800 Subject: [PATCH 2/2] Update koa.md Quick fixes for things i noticed. --- docs/api/koa.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/koa.md b/docs/api/koa.md index 8fb5fe3bda..3d7943fd61 100644 --- a/docs/api/koa.md +++ b/docs/api/koa.md @@ -49,7 +49,7 @@ If no Feathers application is passed, `koa() -> app` returns a plain Koa applica ## app.listen(port) -`app.listen(port) -> HttpServer` will first call Koa [app.listen](http://expressjs.com/en/4x/api.html#app.listen) and then internally also call the [Feathers app.setup(server)](./application.md#setupserver). +`app.listen(port) -> HttpServer` will first call Koa [app.listen](https://github.com/koajs/koa/blob/master/docs/api/index.md#applisten) and then internally also call the [Feathers app.setup(server)](./application.md#setupserver). ```js // Listen on port 3030 @@ -241,7 +241,7 @@ app.use( The `parseAuthentication` middleware is registered automatically and will use the strategies of the default [authentication service](./authentication/service.md) to parse headers for authentication information. If you want to additionally parse authentication with a different authentication service this middleware can be registered again with that service configured. ```ts -import { parseAuthentication } from '@feathersjs/express' +import { parseAuthentication } from '@feathersjs/koa' app.use( parseAuthentication({