Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelpapineau committed Oct 12, 2023
2 parents 2fd4b67 + fd46515 commit 98522b8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ Send Text Message with the following JSON payloads
}
}
```
### `ping` Request

```json
{
"method": "ping"
}
```

## REST API

Expand Down Expand Up @@ -116,4 +123,10 @@ docker run -it --rm --env-file .env ghcr.io/pinax-network/substreams-sink-websoc
## 📖 References

- [**Substreams** documentation](https://substreams.streamingfast.io/)
- [Bun WebSockets](https://bun.sh/docs/api/websockets)
- [Bun WebSockets](https://bun.sh/docs/api/websockets)

Bun's latest v1.0 release includes WebSocket support (written in Zig)
https://bun.sh/docs/api/websockets

Under the hood, it uses uWebSockets
https://github.com/uNetworking/uWebSockets
7 changes: 1 addition & 6 deletions examples/bun/ping.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { randomUUID } from "crypto";

const ws = new WebSocket("ws://localhost:3000");

ws.onopen = () => {
console.log("connected");
ws.send(JSON.stringify({
id: randomUUID(),
method: "ping"
}));
ws.send(JSON.stringify({ method: "ping" }));
};

ws.onmessage = (event) => {
Expand Down
3 changes: 0 additions & 3 deletions examples/bun/subscribe.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { randomUUID } from "crypto";

const ws = new WebSocket("ws://localhost:3000");

ws.onopen = () => {
console.log("connected");
ws.send(JSON.stringify({
id: randomUUID(),
method: "subscribe",
params: {
moduleHash: "0a363b2a63aadb76a525208f1973531d3616fbae"
Expand Down
7 changes: 1 addition & 6 deletions examples/bun/time.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { randomUUID } from "crypto";

const ws = new WebSocket("ws://localhost:3000");

ws.onopen = () => {
console.log("connected");
ws.send(JSON.stringify({
id: randomUUID(),
method: "time"
}));
ws.send(JSON.stringify({method: "time" }));
};

ws.onmessage = (event) => {
Expand Down
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import "dotenv/config";

import pkg from "../package.json" assert { type: "json" };
import { Command, Option } from "commander";
import { logger } from "./logger.js";

// default values
export const DEFAULT_PORT = 3000
Expand Down

0 comments on commit 98522b8

Please sign in to comment.