Rename env to AppContext
This commit is contained in:
@@ -4,7 +4,7 @@ import {Tracker, subscribe as baseSubscribe} from "@welshman/net"
|
|||||||
import type {SubscribeRequest} from "@welshman/net"
|
import type {SubscribeRequest} from "@welshman/net"
|
||||||
import {createEventStore} from "@welshman/store"
|
import {createEventStore} from "@welshman/store"
|
||||||
|
|
||||||
export const env: {
|
export const AppContext: {
|
||||||
BOOTSTRAP_RELAYS: string[]
|
BOOTSTRAP_RELAYS: string[]
|
||||||
DUFFLEPUD_URL?: string
|
DUFFLEPUD_URL?: string
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {writable, derived} from 'svelte/store'
|
|||||||
import {withGetter} from '@welshman/store'
|
import {withGetter} from '@welshman/store'
|
||||||
import {type SubscribeRequest} from "@welshman/net"
|
import {type SubscribeRequest} from "@welshman/net"
|
||||||
import {uniq, uniqBy, batcher, postJson, last} from '@welshman/lib'
|
import {uniq, uniqBy, batcher, postJson, last} from '@welshman/lib'
|
||||||
import {env} from './core'
|
import {AppContext} from './core'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
import {deriveProfile} from './profiles'
|
import {deriveProfile} from './profiles'
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ export type Handle = {
|
|||||||
export const handles = withGetter(writable<Handle[]>([]))
|
export const handles = withGetter(writable<Handle[]>([]))
|
||||||
|
|
||||||
export const fetchHandles = (handles: string[]) => {
|
export const fetchHandles = (handles: string[]) => {
|
||||||
const base = env.DUFFLEPUD_URL!
|
const base = AppContext.DUFFLEPUD_URL!
|
||||||
|
|
||||||
if (!base) {
|
if (!base) {
|
||||||
throw new Error("DUFFLEPUD_URL is required to fetch nip05 info")
|
throw new Error("DUFFLEPUD_URL is required to fetch nip05 info")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {uniq} from '@welshman/lib'
|
|||||||
import {INBOX_RELAYS, RELAYS, getRelayTags, normalizeRelayUrl, type TrustedEvent} from '@welshman/util'
|
import {INBOX_RELAYS, RELAYS, getRelayTags, normalizeRelayUrl, type TrustedEvent} from '@welshman/util'
|
||||||
import {type SubscribeRequest} from "@welshman/net"
|
import {type SubscribeRequest} from "@welshman/net"
|
||||||
import {deriveEvents, withGetter} from '@welshman/store'
|
import {deriveEvents, withGetter} from '@welshman/store'
|
||||||
import {env, load, repository} from './core'
|
import {AppContext, load, repository} from './core'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
|
|
||||||
export const getRelayUrls = (event?: TrustedEvent): string[] =>
|
export const getRelayUrls = (event?: TrustedEvent): string[] =>
|
||||||
@@ -33,12 +33,12 @@ export const {
|
|||||||
load({
|
load({
|
||||||
...request,
|
...request,
|
||||||
filters: [{kinds: [RELAYS], authors: [pubkey]}],
|
filters: [{kinds: [RELAYS], authors: [pubkey]}],
|
||||||
relays: [...env.BOOTSTRAP_RELAYS, ...request.relays || []],
|
relays: [...AppContext.BOOTSTRAP_RELAYS, ...request.relays || []],
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getHintsForPubkey = async (pubkey: string, relays: string[] = []) =>
|
export const getHintsForPubkey = async (pubkey: string, relays: string[] = []) =>
|
||||||
uniq([...relays, ...env.BOOTSTRAP_RELAYS, ...getWriteRelayUrls(await loadRelaySelections(pubkey, {relays}))])
|
uniq([...relays, ...AppContext.BOOTSTRAP_RELAYS, ...getWriteRelayUrls(await loadRelaySelections(pubkey, {relays}))])
|
||||||
|
|
||||||
export const inboxRelaySelections = withGetter(deriveEvents(repository, {filters: [{kinds: [RELAYS]}]}))
|
export const inboxRelaySelections = withGetter(deriveEvents(repository, {filters: [{kinds: [RELAYS]}]}))
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {withGetter} from '@welshman/store'
|
|||||||
import {groupBy, indexBy, batch, now, uniq, uniqBy, batcher, postJson} from '@welshman/lib'
|
import {groupBy, indexBy, batch, now, uniq, uniqBy, batcher, postJson} from '@welshman/lib'
|
||||||
import {type RelayProfile} from "@welshman/util"
|
import {type RelayProfile} from "@welshman/util"
|
||||||
import {AuthStatus, asMessage, type Connection, type SocketMessage} from '@welshman/net'
|
import {AuthStatus, asMessage, type Connection, type SocketMessage} from '@welshman/net'
|
||||||
import {env} from './core'
|
import {AppContext} from './core'
|
||||||
import {createSearch} from './util'
|
import {createSearch} from './util'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ export const relaysByPubkey = derived(relays, $relays =>
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const fetchRelayProfiles = (urls: string[]) => {
|
export const fetchRelayProfiles = (urls: string[]) => {
|
||||||
const base = env.DUFFLEPUD_URL!
|
const base = AppContext.DUFFLEPUD_URL!
|
||||||
|
|
||||||
if (!base) {
|
if (!base) {
|
||||||
throw new Error("DUFFLEPUD_URL is required to fetch relay metadata")
|
throw new Error("DUFFLEPUD_URL is required to fetch relay metadata")
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import {withGetter} from '@welshman/store'
|
|||||||
import {type Zapper} from '@welshman/util'
|
import {type Zapper} from '@welshman/util'
|
||||||
import {type SubscribeRequest} from "@welshman/net"
|
import {type SubscribeRequest} from "@welshman/net"
|
||||||
import {uniq, identity, bech32ToHex, tryCatch, uniqBy, batcher, postJson} from '@welshman/lib'
|
import {uniq, identity, bech32ToHex, tryCatch, uniqBy, batcher, postJson} from '@welshman/lib'
|
||||||
import {env} from './core'
|
import {AppContext} from './core'
|
||||||
import {collection} from './collection'
|
import {collection} from './collection'
|
||||||
import {deriveProfile} from './profiles'
|
import {deriveProfile} from './profiles'
|
||||||
|
|
||||||
export const zappers = withGetter(writable<Zapper[]>([]))
|
export const zappers = withGetter(writable<Zapper[]>([]))
|
||||||
|
|
||||||
export const fetchZappers = (lnurls: string[]) => {
|
export const fetchZappers = (lnurls: string[]) => {
|
||||||
const base = env.DUFFLEPUD_URL!
|
const base = AppContext.DUFFLEPUD_URL!
|
||||||
|
|
||||||
if (!base) {
|
if (!base) {
|
||||||
throw new Error("DUFFLEPUD_URL is required to fetch zapper info")
|
throw new Error("DUFFLEPUD_URL is required to fetch zapper info")
|
||||||
|
|||||||
Reference in New Issue
Block a user