Options
All
  • Public
  • Public/Protected
  • All
Menu

Exposes a Protocol on a TCP port

Hierarchy

  • RestServer

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • Create a new RestServer for the passed protocol. The server will initially be stopped!

    Parameters

    • protocol: Protocol

      Protocol implementation to handle all requests

    Returns RestServer

Properties

server

server: Server

Accessors

listening

listening:

returns true if the server is active and accepting connections.

port

port:

Methods

close

  • close(): Promise<void>
  • Close the server and stop accepting connections. Call listen() to start the server again.

    Returns Promise<void>

listen

  • listen(port?: undefined | number, host?: undefined | string): Promise<void>
  • Start listening for incoming requests. If the port is unavailable, the listen call will be retried every second until the socket is opened successfully or close() is called.

    Parameters

    • Optional port: undefined | number

      TCP port to listen on; omit to use the protocol's default port

    • Optional host: undefined | string

      hostname/IP to bind to; omit for localhost

    Returns Promise<void>

    a promise that resolves once the server is up and running