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
- url
- Type:
String
- summary
- Type:
String
swagger doc
- desc
- Type:
String
swagger doc
- sdkMethodName
- Type:
String
client sdk method name
Parameters:
Throws:
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
res
object. The function's context is always set to theres
object- 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:
Object
orString
orfunction
- self
- name optional
- Type:
String
- fn
- Type:
function
- self
- valDef
- Type:
string
orObject
string => registered validator's name. Object => schema definition
- dataProp
- Type:
string
any of available properties of the
req
object - eg.: query|body|params|headers- 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, ...]
String
returns route's name. If no name has been assigned, the name is dynamically created from route's url path
Returns:String
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
RouteInterface
pushes specifically configured validation middleware to the route's call stack
Parameters:
RouteInterface
Example:
route.validate({
properties: {
username: {type: 'string'}
}
}, 'query');
//or
route.validate('ajv-registered-validation-schema-uid', 'body');