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<void>);
    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?) => Promise<void>);
    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
    • The local address of the server

      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
    • Applies a WebSocket instance to the target

      Parameters

      • target: RouterLike

      Returns void

Param: target

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 the number of connections to the underlying TCP server

      Returns Promise<number>

getMaxConnections: (() => number)

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

Type declaration

    • (): number
    • Retrieves the maximum number of connections that the underlying TCP server will accept

      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 the WebSocket.Server instance attached to the application

      Returns Server<typeof WebSocket, typeof IncomingMessage>

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

Installs the cloudflared binary

Type declaration

    • (): Promise<void>
    • Installs the cloudflared binary

      Returns Promise<void>

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>
    • 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.

      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
    • Serves a static path via the Express application

      Parameters

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

      Returns void

Param: local_path

Param: options

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
    • Sets the maximum number of connections that the underlying TCP server will accept

      Parameters

      • maximum: number

      Returns void

Param: maximum

ssl: Readonly<boolean>

If SSL is enabled

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

Starts the server

Type declaration

    • (): Promise<void>
    • Starts the server

      Returns Promise<void>

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

Stops the server

Type declaration

    • (): Promise<void>
    • Stops the server

      Returns Promise<void>

tunnelConnections?: readonly Connection[]

The cloudflared tunnel connections

tunnelStart: ((maxRetries?) => Promise<void>)

Starts a temporary cloudflared tunnel to cloudflare

Type declaration

    • (maxRetries?): Promise<void>
    • Starts a temporary cloudflared tunnel to cloudflare

      Parameters

      • Optional maxRetries: number

      Returns Promise<void>

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

Stops the cloudflared tunnel

Type declaration

    • (): Promise<void>
    • Stops the cloudflared tunnel

      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>
    • 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.

      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

    • (route, ...middlewares): void
    • Creates a WebSocket route in the same kind of format as .get/.post/etc

      Parameters

      Returns void

Param: route

Param: middlewares