Class HttpServer

Represents an HTTP server.

Hierarchy

  • HttpServer

Constructors

  • Creates a new instance of the HttpServer class.

    Parameters

    • port: number

      The port number for the server to listen on.

    • supportWebsocket: boolean

      Determines whether to support WebSocket connections.

    Returns HttpServer

Properties

app: Application
basicAuthenticationEnabled: boolean = false
cookieName: string = null
credentials: {
    password: string;
    user: string;
}[] = ...

Type declaration

  • password: string
  • user: string
indexCache: Buffer
isServerStarted: boolean = false
port: number

The port number for the server to listen on.

server: Server
serverStartedResolves: Function[] = []
supportWebsocket: boolean

Determines whether to support WebSocket connections.

websocket: WebsocketServer
deleteMethods: HttpMethod[] = ...
fileProvider: FileProvider[] = ...
getMethods: HttpMethod[] = ...
imageProvider: ImageProvider[] = ...
postMethods: HttpMethod[] = ...
putMethods: HttpMethod[] = ...

Accessors

  • get App(): Application
  • Gets the underlying Express application instance.

    Returns Application

    The Express application instance.

Methods

  • Adds credentials for basic authentication.

    Parameters

    • user: string

      The username.

    • password: string

      The password.

    Returns void

  • Waits for the server to start listening for requests.

    Returns Promise<boolean>

    A promise that resolves when the server has started.

  • Returns the name property for the auth cookie. This cookie is used for FileProvider/ImageProvider Authentication. Returns null if cookie authentication is disabled.

    Returns string

    The the name of the cookie used for authentication or null if cookies are disabled for authentication.

  • Parameters

    Returns RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

  • Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

    Returns {
        name: string;
        value: string;
    }[]

  • Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • provider: FileProvider
    • Optional id: string
    • Optional auth: string

    Returns Promise<void>

  • Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>
    • provider: ImageProvider
    • Optional id: string
    • Optional auth: string

    Returns Promise<void>

  • Defines the name property for the auth cookie. This cookie is used for FileProvider/ImageProvider Authentication.

    Parameters

    • name: string

      the name of the cookie used for authentication.

    Returns void

  • Sets up file serving for an Angular application.

    Parameters

    • path: string

      The path to the Angular application build files.

    Returns void

  • Sets up file serving for static assets.

    Parameters

    • path: string

      The path to the directory containing the static assets.

    Returns void

  • Stops the server from accepting new connections and keeps existing connections. This function is asynchronous, and the server is finally closed when all connections are ended and the server emits a 'close' event.

    Returns Promise<void>

    A promise that is resolved once all connections are closed.

Generated using TypeDoc