HTTPServer class

const httpServer = new HTTPServer(port?: number);

constructor

The constructor of the HTTPServer class requires one argument. The argument must be a type of number and defines the port where the HTTP server has to listen to.

Properties

get

An instance of the NodeJS built-in EventEmitter class and gets emitted for every GET request made to the server. The name of each event is the path which has been requested from the client's side.

EventDescriptionArguments

Path name of the request

Gets emitted when the client makes a GET request to the HTTP server.

The get EventEmitter supports placeholders. Placeholders can be used to add variables in the paths of pages. A placeholder can be set by adding a {*} in the path. The corresponding placeholder will be returned in the requestInfo class.

post

An instance of the NodeJS built-in EventEmitter class and gets emitted for every POST request made to the server. The name of each event is the path which has been requested from the client's side.

EventDescriptionArguments

Path name of the request

Gets emitted when the client makes a GET request to the HTTP server.

The post EventEmitter supports placeholders. Placeholders can be used to add variables in the paths of pages. A placeholder can be set by adding a {*} in the path. The corresponding placeholder will be returned in the requestInfo class.

errorMessages

An array with all the error messages received during the requests made by the client.

Last updated