8000 chore(docs): Provide uWS setup for Socket.IO + Koa corrections by 8BallBomBom · Pull Request #3263 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api/koa.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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({
Expand Down
28 changes: 28 additions & 0 deletions docs/api/socketio.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,34 @@ Try to avoid listening and sending events on the `socket` directly since it circ

</BlockQuote>

#### 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.
Expand Down
0