nbd-wtf / nostr-tools

Tools for developing Nostr clients.
The Unlicense
706 stars 197 forks source link

Do we have the full documentation about how to use the nostr-tools API? #316

Closed Tingwei-Justin closed 10 months ago

Tingwei-Justin commented 11 months ago

i have a n00b question, do we have a documentation about the API? For example, how to use below's API. This is not very friendly to easily onboarding for new people. Thank you so much!

export declare class SimplePool {
    private _conn;
    private _seenOn;
    private eoseSubTimeout;
    private getTimeout;
    constructor(options?: {
        eoseSubTimeout?: number;
        getTimeout?: number;
    });
    close(relays: string[]): void;
    ensureRelay(url: string): Promise<Relay>;
    sub<K extends number = number>(relays: string[], filters: Filter<K>[], opts?: SubscriptionOptions): Sub<K>;
    get<K extends number = number>(relays: string[], filter: Filter<K>, opts?: SubscriptionOptions): Promise<Event<K> | null>;
    list<K extends number = number>(relays: string[], filters: Filter<K>[], opts?: SubscriptionOptions): Promise<Event<K>[]>;
    publish(relays: string[], event: Event<number>): Pub;
    seenOn(id: string): string[];
}
fiatjaf commented 11 months ago

We don't have it, hopefully we will have more documentation written as jsdoc comments or whatever people use these days eventually, but if you are a programmer you MUST be able to read the code and understand roughly what it does. Also you should use an LSP so the types are shown to you inside your editor as you type. Also you shouldn't use JavaScript (or TypeScript) unless absolutely necessary, it's bad.