Shoukaku
    Preparing search index...

    Interface RestEndpoint

    Routes should implement this interface to use with fetch function

    Properties can be a value, or a function that returns a value to access this

    Example with LavaSearch /loadsearch endpoint

    	export class LoadSearchEndpoint implements RestEndpoint {
    constructor(public readonly query: string, public readonly types: string) {}

    public readonly pluginRequired = {
    name: 'lavasearch-plugin',
    version: '^1.0.0'
    };

    public readonly endpoint = '/loadsearch';
    public readonly params = () => ({ query: this.query, types: this.types });

    public readonly T = t<{
    tracks?: Track[];
    albums?: Playlist[];
    artists?: Playlist[];
    playlists?: Playlist[];
    texts?: {
    text: string;
    plugin: Record<string, unknown>;
    };
    plugin: Record<string, unknown>;
    }>;
    }
    interface RestEndpoint {
        body?: FnOrVal<Record<string, unknown> | undefined>;
        endpoint: FnOrVal<string>;
        headers?: FnOrVal<Record<string, string> | undefined>;
        method?: HintedString<"DELETE" | "GET" | "PATCH" | "POST" | "PUT">;
        params?: FnOrVal<Record<string, string> | undefined>;
        pluginRequired?: PluginRequirement;
        T: TFn;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    body?: FnOrVal<Record<string, unknown> | undefined>

    JSON body to send with

    endpoint: FnOrVal<string>

    Lavalink endpoint

    headers?: FnOrVal<Record<string, string> | undefined>

    HTTP request headers

    method?: HintedString<"DELETE" | "GET" | "PATCH" | "POST" | "PUT">

    HTTP request method, GET by default

    params?: FnOrVal<Record<string, string> | undefined>

    URL params

    pluginRequired?: PluginRequirement

    Plugin required by endpoint

    T: TFn

    This hack is to work around TypeScript types not existing at runtime. We can specify the return type here.

    This function is never actually called, so the implementation can be simply:

    T = (response: unknown) => response as LavalinkResponse;
    

    Or using the t utility function

    import { t } from 'shoukaku';

    T = t<LavalinkResponse>;