Extends
Members
tries to determine the route definition location
Type:
String
unique identifier of the route
Type:
String
Constructor
- options
- Type:
Object - name optional
- Type:
String - type
- Type:
String see
RequestTypeenum for available option values- url
- Type:
String - summary
- Type:
String document the end point
- desc
- Type:
String document the end point
- sdkMethodName
- Type:
String sdk method name for API clients
Parameters:
Throws:
Methods
- pathParams optional
- Type:
Object - queryParams optional
- Type:
Object - pathParams optional
- Type:
Object - queryParams optional
- Type:
Object - valDef
- Type:
stringorObject string => registered validator's name. Object => schema definition
- dataProp
- Type:
string query|body|params|headers
- self
String
returns absolute route endpoint.
In order to work properly service config option apps.<app-name>.baseUrl should be set
Parameters:
String
String
returns route's name. If no name has been assigned, the name is dynamically created from route's url path
Returns:String
String
returns hostname relative route endpoint
Parameters:
String
Route
pushes specifically configured validation middleware to the route's call stack
Parameters:
Route
Example:
route.validate({
properties: {
username: {type: 'string'}
}
}, 'query');
//or
route.validate('ajv-registered-validation-schema-uid', 'body');
Inherited Methods
- type
- Type:
String Content-Type header value
- options optional
- Type:
Object - limit optional
- Type:
String data size limit
- parser optional
- Type:
function custom data parser function - must return a Promise
- name optional
- Type:
String - fn
- Type:
function - self
- cb
- Type:
function callback function which sets response on the express
resobject. The function's context is always set to theresobject- filter optional
- Type:
function must be a constructor with .prototype property that is instanceof Error
- callback
- Type:
function - self
- fn
- Type:
function - self
- type
- Type:
String Content-Type header value
- descriptor
- Type:
ObjectorStringorfunction - self
- name optional
- Type:
String - fn
- Type:
function - self
[String, ...]
returns collection of supported request content mime types
Returns:[String, ...]
RouteInterface
define which content-type headers the route supports.
this is also gonna register and manage a single validation middleware for content-type header internally
Parameters:
RouteInterface
RouteInterface
allows to hook up any middleware function to the request promise chain (call stack)
Parameters:
RouteInterface
Response
the Response object can be returned from within route middleware which will cause promise call chain interruption of current request and prioritized response
Parameters:
Response
Example:
route.step(function() {
return route.buildResponse(function() {
this.json({response: 'data'});
}):
}).step(function() {
//will never be called
});
RouteInterface
catch promise stack handler invoked when an Error occurs while executing one of the route middlwares
Parameters:
RouteInterface
Example:
route.main(function() {
throw new TypeError('test');
}).catch(TypeError, function(err, req, res) {
//err handler logic
});
[Object, ...]
returns route's internal middleware call stack
Returns:[Object, ...]
RouteInterface
Parameters:
RouteInterface
Example:
route.main(() => {})
//is same as:
route.step('main', () => {})
RouteInterface
define a content-type which should be always rejected by this route.
Content types black listed by this method can be later white listed by the
RouteInterface#acceptsContentType method
Parameters:
RouteInterface
RouteInterface
allows to describe route's response data format in form of Ajv validation
schema object or Error instance object/constructor which implements toSwagger method.
if a string is provided it's expected to be validation schema unique indentifier
registered with the Ajv instance.
With res.filter({some: 'data'}).json() conjuction, data can be filtered
with defined response schema.
Parameters:
RouteInterface
Example:
route.respondsWith({
type: 'object',
additionalProperties: false,
properties: {
prop1: {type: 'string'}
}
});
route.main(function(req, res) {
res.filter({prop1: 'included', prop2: 'filtered out'}).json();
});
RouteInterface
alias for RouteInterface#addStep
Parameters:
RouteInterface