Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/realpeha/nengi-bun-server-adapter
Bun web socket server network adapter for nengi v2
https://github.com/realpeha/nengi-bun-server-adapter
bun nengi websocket ws
Last synced: about 2 months ago
JSON representation
Bun web socket server network adapter for nengi v2
- Host: GitHub
- URL: https://github.com/realpeha/nengi-bun-server-adapter
- Owner: RealPeha
- Created: 2023-09-15T17:35:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-15T18:10:20.000Z (over 1 year ago)
- Last Synced: 2024-11-10T07:41:59.603Z (about 2 months ago)
- Topics: bun, nengi, websocket, ws
- Language: TypeScript
- Homepage: https://npmjs.com/package/nengi-bun-server-adapter
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [Bun](https://bun.sh/) web socket server network adapter for nengi v2
> **Warning**
> This adapter is written and tested only on nengi v2.0.0-alpha.138, this is an unstable version, the api of which may change in the future### Install
```bash
bun add nengi-bun-server-adapter
```### Usage
#### Server-side
```ts
import { Instance, Context } from "nengi";
import { BunServerAdapter } from "nengi-bun-server-adapter";const ctx = new Context();
// <...>
const instance = new Instance(ctx);const adapter = new BunServerAdapter(instance.network);
adapter.listen(PORT);
```Adapter internally uses Bun.serve so if you want to pass additional options for the Bun.serve you can pass them as the second argument
```ts
const adapter = new BunServerAdapter(instance.network, {
lowMemoryMode: true,
websocket: {
sendPings: false,
},
});
```All available Bun.serve options is described here https://bun.sh/docs/api/websockets
#### Client-side
For client-side you need any web socket adapter, for example [nengi-websocket-client-adapter](https://github.com/timetocode/nengi-websocket-client-adapter)