Class: Base

http.Base

new Base(optionsnullable)

HTTPBase

Parameters:
Name Type Attributes Description
options Object <nullable>
Source:
Fires:
  • HTTPBase#event:websocket

Members

(private) handleHooks

Handle hook stack.

Source:

(private) handleRequest

Handle a request.

Source:

(private) handleStack

Handle middleware stack.

Source:

(private) parseBody

Parse request body.

Source:

Methods

(private) _init()

Initialize server.

Source:

(private) _initIO()

Initialize websockets.

Source:

(private) _initRouter()

Initialize router.

Source:

(private) _readBody(req, enc, resolve, reject)

Read and buffer request body.

Parameters:
Name Type Description
req ServerRequest
enc String
resolve function
reject function
Source:

address() → {Object}

Get server address.

Source:
Returns:
Type
Object

del(path, handler, ctxnullable)

Add a DELETE route.

Parameters:
Name Type Attributes Description
path String
handler function
ctx Object <nullable>
Source:

get(path, handler, ctxnullable)

Add a GET route.

Parameters:
Name Type Attributes Description
path String
handler function
ctx Object <nullable>
Source:

hook(pathnullable, handler, ctxnullable)

Add a hook to the stack.

Parameters:
Name Type Attributes Description
path String <nullable>
handler function
ctx Object <nullable>
Source:

listen(port, host) → {Promise}

Listen on port and host.

Parameters:
Name Type Description
port Number
host String
Source:
Returns:
Type
Promise

post(path, handler, ctxnullable)

Add a POST route.

Parameters:
Name Type Attributes Description
path String
handler function
ctx Object <nullable>
Source:

put(path, handler, ctxnullable)

Add a PUT route.

Parameters:
Name Type Attributes Description
path String
handler function
ctx Object <nullable>
Source:

readBody(req, enc) → {Promise}

Read and buffer request body.

Parameters:
Name Type Description
req ServerRequest
enc String
Source:
Returns:
Type
Promise

use(pathnullable, handler, ctxnullable)

Add a middleware to the stack.

Parameters:
Name Type Attributes Description
path String <nullable>
handler function
ctx Object <nullable>
Source: