uWebSockets.js v20.60.0 documentation
    Preparing search index...

    Interface TemplatedApp

    TemplatedApp is either an SSL or non-SSL app. See App for more info, read user manual.

    interface TemplatedApp {
        addServerName(hostname: string, options: AppOptions): TemplatedApp;
        any(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        close(): TemplatedApp;
        connect(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        del(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        domain(domain: string): TemplatedApp;
        filter(
            cb: (res: HttpResponse, count: Number) => void | Promise<void>,
        ): TemplatedApp;
        get(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        head(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        listen(
            host: RecognizedString,
            port: number,
            cb: (listenSocket: false | us_listen_socket) => void | Promise<void>,
        ): TemplatedApp;
        listen(
            host: RecognizedString,
            port: number,
            options: ListenOptions,
            cb: (listenSocket: false | us_listen_socket) => void | Promise<void>,
        ): TemplatedApp;
        listen(
            port: number,
            cb: (listenSocket: false | us_listen_socket) => void | Promise<void>,
        ): TemplatedApp;
        listen(
            port: number,
            options: ListenOptions,
            cb: (listenSocket: false | us_listen_socket) => void | Promise<void>,
        ): TemplatedApp;
        listen_unix(
            cb: (listenSocket: us_listen_socket) => void | Promise<void>,
            path: RecognizedString,
        ): TemplatedApp;
        missingServerName(cb: (hostname: string) => void): TemplatedApp;
        numSubscribers(topic: RecognizedString): number;
        options(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        patch(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        post(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        publish(
            topic: RecognizedString,
            message: RecognizedString,
            isBinary?: boolean,
            compress?: boolean,
        ): boolean;
        put(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        removeServerName(hostname: string): TemplatedApp;
        trace(
            pattern: RecognizedString,
            handler: (res: HttpResponse, req: HttpRequest) => void | Promise<void>,
        ): TemplatedApp;
        ws<UserData>(
            pattern: RecognizedString,
            behavior: WebSocketBehavior<UserData>,
        ): TemplatedApp;
    }
    Index

    Methods

    • Browse to SNI domain. Used together with .get, .post and similar to attach routes under SNI domains.

      Parameters

      • domain: string

      Returns TemplatedApp

    • Registers a synchronous callback on missing server names. See /examples/ServerName.js.

      Parameters

      • cb: (hostname: string) => void

      Returns TemplatedApp

    post