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