Interface WebApplication

Extends an Express.Application see https://expressjs.com/en/4x/api.html#app

interface WebApplication {
    address: (() => null | string | AddressInfo);
    appOptions: Readonly<WebApplicationOptions>;
    applyTo?: ((target) => void);
    bindHost: string;
    bindPort: number;
    cloudflared?: string;
    getConnections: (() => Promise<number>);
    getMaxConnections: (() => number);
    getWss: (() => Server<typeof WebSocket, typeof IncomingMessage>);
    installCloudflared: (() => Promise<undefined | string>);
    localUrl: string;
    ref: (() => Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>);
    serveStatic: ((local_path, options?) => void);
    server: Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>;
    setMaxConnections: ((maximum) => void);
    ssl: Readonly<boolean>;
    start: (() => Promise<void>);
    stop: (() => Promise<void>);
    tunnelConnections?: readonly Connection[];
    tunnelStart: ((maxRetries?, timeout?) => Promise<boolean>);
    tunnelStop: (() => Promise<void>);
    tunnelUrl?: string;
    unref: (() => Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>);
    url: string;
    ws: ((route, ...middlewares) => void);
    (req, res): any;
    (req, res, next): void;
}

Hierarchy

  • Application
  • Readonly<ROWebApplicationProperties>
    • WebApplication
  • Express instance itself is a request handler, which could be invoked without third argument.

    Parameters

    • req: IncomingMessage | Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: ServerResponse<IncomingMessage> | Response<any, Record<string, any>, number>

    Returns any

  • Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>, number>
    • next: NextFunction

    Returns void

Properties

address: (() => null | string | AddressInfo)

The local address of the server

Type declaration

    • (): null | string | AddressInfo
    • Returns null | string | AddressInfo

appOptions: Readonly<WebApplicationOptions>

The options used to create the application

applyTo?: ((target) => void)

Applies a WebSocket instance to the target

Type declaration

    • (target): void
    • Parameters

      • target: RouterLike

      Returns void

bindHost: string

The host address that we are to bind to

bindPort: number

The port that we are to bind to

cloudflared?: string

Path to cloudflared binary

getConnections: (() => Promise<number>)

Returns the number of connections to the underlying TCP server

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

getMaxConnections: (() => number)

Retrieves the maximum number of connections that the underlying TCP server will accept

Type declaration

    • (): number
    • Returns number

getWss: (() => Server<typeof WebSocket, typeof IncomingMessage>)

Returns the WebSocket.Server instance attached to the application

Type declaration

    • (): Server<typeof WebSocket, typeof IncomingMessage>
    • Returns Server<typeof WebSocket, typeof IncomingMessage>

installCloudflared: (() => Promise<undefined | string>)

Installs the cloudflared binary

Type declaration

    • (): Promise<undefined | string>
    • Returns Promise<undefined | string>

localUrl: string

The local server URL

ref: (() => Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>)

Opposite of unref(), calling ref() on a previously unrefed server will not let the program exit if it's the only server left (the default behavior). If the server is refed calling ref() again will have no effect.

Type declaration

    • (): Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>
    • Returns Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>

serveStatic: ((local_path, options?) => void)

Serves a static path via the Express application

Type declaration

    • (local_path, options?): void
    • Parameters

      • local_path: string
      • Optional options: ServeStaticOptions<ServerResponse<IncomingMessage>>

      Returns void

server: Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>

The underlying HTTP/S server

setMaxConnections: ((maximum) => void)

Sets the maximum number of connections that the underlying TCP server will accept

Type declaration

    • (maximum): void
    • Parameters

      • maximum: number

      Returns void

ssl: Readonly<boolean>

If SSL is enabled

start: (() => Promise<void>)

Starts the server

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

stop: (() => Promise<void>)

Stops the server

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

tunnelConnections?: readonly Connection[]

The cloudflared tunnel connections

tunnelStart: ((maxRetries?, timeout?) => Promise<boolean>)

Starts a temporary cloudflared tunnel to cloudflare

Type declaration

    • (maxRetries?, timeout?): Promise<boolean>
    • Parameters

      • Optional maxRetries: number
      • Optional timeout: number

      Returns Promise<boolean>

tunnelStop: (() => Promise<void>)

Stops the cloudflared tunnel

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

tunnelUrl?: string

The cloudflared tunnel url

unref: (() => Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>)

Calling unref() on a server will allow the program to exit if this is the only active server in the event system. If the server is already unrefed calling unref() again will have no effect.

Type declaration

    • (): Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>
    • Returns Server<typeof IncomingMessage, typeof ServerResponse> | Server<typeof IncomingMessage, typeof ServerResponse>

url: string

The common server URL

ws: ((route, ...middlewares) => void)

Creates a WebSocket route in the same kind of format as .get/.post/etc

Type declaration