Add a few utils, fix relay fetching

This commit is contained in:
Jon Staab
2025-12-12 13:28:48 -08:00
parent 483fff2fbb
commit 780148a31e
3 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ export const onRelay = (sub: (relay: RelayProfile) => void) => {
export const fetchRelayDirectly = async (url: string): Promise<Maybe<RelayProfile>> => {
try {
const json = fetchJson(url.replace(/^ws/, "http"), {
const json = await fetchJson(url.replace(/^ws/, "http"), {
headers: {
Accept: "application/nostr+json",
},
+7 -3
View File
@@ -6,6 +6,8 @@ export type Maybe<T> = T | undefined
export type MaybeAsync<T> = T | Promise<T>
export const maybe = <T>(x?: T) => x
export const isDefined = <T>(x: T, ...args: unknown[]) => x !== undefined
export const isUndefined = <T>(x: T, ...args: unknown[]) => x === undefined
@@ -1034,9 +1036,11 @@ export const tryCatch = <T>(f: () => T, onError?: (e: Error) => void): T | undef
/**
* Throws an error with the given message
*/
export const thrower = (message: string) => () => {
throw new Error(message)
}
export const thrower =
(message: string) =>
(...args: unknown[]) => {
throw new Error(message)
}
/**
* Creates function that only executes once
+2 -2
View File
@@ -138,8 +138,10 @@ export const EMOJIS = 10030
export const MESSAGING_RELAYS = 10050
export const BLOSSOM_SERVERS = 10063
export const FILE_SERVERS = 10096
export const WALLET_INFO = 13194
export const RELAY_MEMBERS = 13534
export const PROMENADE_REGISTER_ACCOUNT = 16430
export const ROOM_CREATE_PERMISSION = 19004
export const LIGHTNING_PUB_RPC = 21000
export const CLIENT_AUTH = 22242
export const BLOSSOM_AUTH = 24242
@@ -152,7 +154,6 @@ export const PROMENADE_RESULT = 26433
export const RELAY_JOIN = 28934
export const RELAY_INVITE = 28935
export const RELAY_LEAVE = 28936
export const WALLET_INFO = 13194
export const WALLET_REQUEST = 23194
export const WALLET_RESPONSE = 23195
export const NOSTR_CONNECT = 24133
@@ -199,7 +200,6 @@ export const ROOM = 35834
export const ROOM_META = 39000
export const ROOM_ADMINS = 39001
export const ROOM_MEMBERS = 39002
export const ROOM_CREATE_PERMISSION = 39004
export const FOLLOW_PACK = 39089
export const DEPRECATED_RELAY_RECOMMENDATION = 2