node.ts
1 import { API_URL } from "./constants" 2 3 export interface NodeConfig { 4 alias: string 5 listen: Array<string> 6 peers: { 7 type: "dynamic" 8 } 9 onion?: { 10 mode: "proxy" 11 address: string 12 } 13 connect: Array<string> 14 externalAddresses: Array<string> 15 network: "main" 16 log: "INFO" 17 relay: "auto" | "always" 18 limits: { 19 routingMaxSize: number 20 routingMaxAge: number 21 gossipMaxAge: number 22 fetchConcurrency: number 23 maxOpenFiles: number 24 rate: { 25 inbound: { 26 fillRate: number 27 capacity: number 28 } 29 outbound: { 30 fillRate: number 31 capacity: number 32 } 33 } 34 connection: { 35 inbound: number 36 outbound: number 37 } 38 fetchPackReceive: string 39 } 40 workers: number 41 seedingPolicy: { 42 default: "block" | "allow" 43 scope?: "all" 44 } 45 } 46 47 export interface Node { 48 id: string; 49 agent: string; 50 config: NodeConfig 51 state: "running" 52 avatarUrl?: string 53 bannerUrl?: string 54 description: string 55 } 56 57 export const getNode = async (): Promise<Node> => 58 fetch(API_URL + "/node") 59 .then(res => res.json())