Files
nosterm-client/src/lib/db/repositories/relay-repository.ts
T
Robert Goodall cd2b900639
ci / build (push) Successful in 1m3s
ci / image (push) Successful in 41s
Initial commit: Nosterm client (terminal-style Nostr chat SPA)
2026-07-24 13:47:53 -04:00

19 lines
562 B
TypeScript

import { getDb, type RelayRecord } from '../database';
import { normalizeRelayUrl } from '$lib/utils/relay-url';
/** storage for the relays the user has added. */
export const relayRepository = {
async list(): Promise<RelayRecord[]> {
return getDb().relays.orderBy('addedAt').toArray();
},
async add(url: string): Promise<void> {
const normalized = normalizeRelayUrl(url);
await getDb().relays.put({ url: normalized, addedAt: Date.now() });
},
async remove(url: string): Promise<void> {
await getDb().relays.delete(normalizeRelayUrl(url));
}
};