A module object represents module default object.
+ new Module(): Module
Returns: Module
▸ 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.
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(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.
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(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.
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(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.
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(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.
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(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.
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(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.
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(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.
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(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.
Name | Type | Description |
---|---|---|
url |
string | original URL string |
Returns: string
resolved URL, points to mock server
▸ use(path
: string, ...callback
: CallbackFunc[]): Server
Uses the specified middleware function or functions.
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