Skip to content

Instantly share code, notes, and snippets.

@crudmont
crudmont / relay.ts
Created November 23, 2024 07:33 — forked from cmdruid/relay.ts
Shameless copy of https://github.com/coracle-social/bucket, updated to ESM with types, validation and minimal dependencies. (<300 LOC)
import { z } from 'zod'
import { schnorr } from '@noble/curves/secp256k1'
import { sha256 } from '@noble/hashes/sha256'
import { WebSocket, WebSocketServer } from 'ws'
/* ================ [ Configuration ] ================ */
const SERVER_PORT = 8002 // Port to use for the server.
const PURGE_IVAL = 600 // Interval to purge events (in seconds).