46 lines
1.1 KiB
Markdown
46 lines
1.1 KiB
Markdown
# Stardust Relay Client
|
|
|
|
A TypeScript client for the Stardust Relay
|
|
|
|
## Getting Started
|
|
|
|
To install through an NPM-compatible package manager, start by configuring your package manager to know about Campgrounds packages. If using [Bun](https://bun.sh) for example, configure your `bunfig.toml` file:
|
|
|
|
```toml
|
|
[install.scopes]
|
|
# Use the Campgrounds NPM repository
|
|
campgrounds = "https://git.astral.camp/api/packages/campgrounds/npm/"
|
|
```
|
|
|
|
Then, install the package:
|
|
|
|
```shell
|
|
bun add @campgrounds/relay-client
|
|
```
|
|
|
|
## Events
|
|
|
|
Real-time events are exposed from the client as topics which you can subscribe any number of listeners to:
|
|
|
|
```typescript
|
|
const client = new RelayClient(API_KEY);
|
|
|
|
client.Events.Chat.new.subscribe(message => {
|
|
console.log("Incoming message:", message);
|
|
})
|
|
```
|
|
|
|
The following events are available to subscribe to:
|
|
|
|
- `Events.Chat.new`
|
|
- `Events.Chat.deleted`
|
|
- `Events.Post.new`
|
|
- `Events.Stream.live`
|
|
- `Events.Stream.request`
|
|
- `Events.Stream.follow`
|
|
- `Events.Stream.subscription`
|
|
- `Events.Stream.giftedSubscription`
|
|
- `Events.Stream.massGiftedSubscription`
|
|
- `Events.Stream.raid`
|
|
- `Events.Stream.cheer`
|
|
- `Events.custom`
|