Initial commit: Nosterm client (terminal-style Nostr chat SPA)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user