Skip to content

Latest commit

 

History

History
237 lines (138 loc) · 6.79 KB

module.md

File metadata and controls

237 lines (138 loc) · 6.79 KB

Class: Module

A module object represents module default object.

Table of contents

Constructors

Methods

Constructors

constructor

+ new Module(): Module

Returns: Module

Methods

all

all(path: string, ...callback: CallbackFunc[]): Server

This method is just like the get,head,post,... methods, except that it matches all HTTP methods (verbs).

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


delete

delete(path: string, ...callback: CallbackFunc[]): Server

Routes HTTP DELETE requests to the specified path with the specified callback functions.

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


get

get(path: string, ...callback: CallbackFunc[]): Server

Routes HTTP GET requests to the specified path with the specified callback functions.

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


head

head(path: string, ...callback: CallbackFunc[]): Server

Routes HTTP HEAD requests to the specified path with the specified callback functions.

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


options

options(path: string, ...callback: CallbackFunc[]): Server

Routes HTTP OPTIONS requests to the specified path with the specified callback functions.

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


patch

patch(path: string, ...callback: CallbackFunc[]): Server

Routes HTTP PATCH requests to the specified path with the specified callback functions.

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


post

post(path: string, ...callback: CallbackFunc[]): Server

Routes HTTP POST requests to the specified path with the specified callback functions.

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


put

put(path: string, ...callback: CallbackFunc[]): Server

Routes HTTP PUT requests to the specified path with the specified callback functions.

You can provide multiple callback functions that behave just like middleware.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API


resolve

resolve(url: string): string

Resolve URL to mock URL, replace host and port with mock server's host and por value.

Only external URLs are resolved, URLs are already pointing to mock server will remain untouched.

Parameters

Name Type Description
url string original URL string

Returns: string

resolved URL, points to mock server


use

use(path: string, ...callback: CallbackFunc[]): Server

Uses the specified middleware function or functions.

Parameters

Name Type Description
path string The path for which the callback function is invoked (string or path pattern)
...callback CallbackFunc[] Callback functions (middlewares or request handler)

Returns: Server

The instance for fluent/chaining API