feat: use close relays

This commit is contained in:
2023-11-17 20:03:59 +00:00
parent 55c938961f
commit 588c3756fd
8 changed files with 146 additions and 9 deletions

View File

@ -68,6 +68,16 @@ export interface TranslationResponse {
}>;
}
export interface RelayDistance {
url: string;
distance: number;
users: number;
country?: string;
city?: string;
is_paid?: boolean;
description?: string;
}
export default class SnortApi {
#url: string;
#publisher?: EventPublisher;
@ -121,6 +131,10 @@ export default class SnortApi {
return this.#getJson<TranslationResponse | object>("api/v1/translate", "POST", tx);
}
closeRelays(lat: number, lon: number, count = 5) {
return this.#getJson<Array<RelayDistance>>(`api/v1/relays?count=${count}`, "POST", { lat, lon });
}
async #getJsonAuthd<T>(
path: string,
method?: "GET" | string,