import { NRelay1 } from "@nostrify/nostrify"; import config from "./config.ts"; export interface NEvent { content: string; created_at: number; id: string; kind: number; pubkey: string; sig: string; tags: Array<[string, string, string?]>; } export const relay = new NRelay1(config.home_relay_url); export async function fetchReplaceableEvent( pubkey: string, identifier: string, ) { const events = await relay.query([{ authors: [pubkey], kinds: [30023], "#d": [identifier], limit: 1, }]); return events.length > 0 ? events[0] : null; } export async function fetchArticlesByAuthor(pubkey: string) { const events = await relay.query([{ authors: [pubkey], kinds: [30023], limit: 10, }]); return events; } export async function fetchProfileEvent(pubkey: string) { const events = await relay.query([{ authors: [pubkey], kinds: [0], limit: 1, }]); return events.length > 0 ? events[0] : null; }