decentralised sync engine
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: prism helper

serenity c5f251d7 8c780135

+26
+26
src/lib/utils/prism.ts
··· 1 + // Prism is a jetstream/jetstream-compatible fork for receiving filtered events from the firehose 2 + import { PRISM_URL } from "@/lib/env"; 3 + import WebSocket from "ws"; 4 + 5 + export const connectToPrism = ({ 6 + wantedCollections, 7 + wantedDids, 8 + cursor, 9 + }: { 10 + wantedCollections?: Array<string>; 11 + wantedDids?: Array<string>; 12 + cursor: number; 13 + }) => { 14 + const endpoint = PRISM_URL; 15 + if (wantedCollections) 16 + wantedCollections.forEach((collection) => { 17 + endpoint.searchParams.append("wantedCollections", collection); 18 + }); 19 + if (wantedDids) 20 + wantedDids.forEach((did) => { 21 + endpoint.searchParams.append("wantedDids", did); 22 + }); 23 + if (cursor) endpoint.searchParams.append("cursor", cursor.toString()); 24 + 25 + return new WebSocket(endpoint); 26 + };