Class: RequestHandler

RequestHandler


new RequestHandler(application, options)

Variables

 - {Object}  route   JSON containing the routes to use
 - {String}  key     session key to be used to store interim results
Parameters:
Name Type Description
application String

Session's application name

options Object
Properties
Name Type Description
useMiddlewareErrorHandler Boolean

if true, uses the Middleware error handler, else will redirect to the error route ("/error" by default)

route.error String

path to the default error route ('/error' by default)

Source:

Methods


<protected> _addToSet(set, elements, property:)

Add 'elements' to 'set' only if they aren't already present

Parameters:
Name Type Description
set Array

(possibly modifed after this method gets executed)

elements Array | any

: Do nothing if 'elements' is null or an empty Array

property: String

name of the property to add (dotted name ok)

Source:
Returns:

the elements which were added into 'set' (empty array if none)

Type
Array

<protected> _createObject( [type] [, object])

Create a DBObject, Event if 'type' is nully or of type 'type' otherwise

Parameters:
Name Type Argument Description
type String <optional>

classname of the object to create (with or without an ending "Mongo")

object Object <optional>

to pass to the constructor

Source:

<protected> _getDebug(req)

Get the full debug object

Parameters:
Name Type Description
req Request
Source:
Returns:

structured as {activated, count}; object is never null and activated always set (to false if "common.debug" didn't exist)

Type
Object

<protected> _processAndCreateError(message, err, req)

Process an error and create a GenericError

Parameters:
Name Type Description
message String
err Error
req Express.Request
Source:
Returns:
Type
GenericError

<protected> _setParamValue(obj, property, value [, type])

Set 'obj' to 'value' if 'value' is !== undefined

Parameters:
Name Type Argument Description
obj Object
property String
value any
type String <optional>

type of the value being set (date)

Source:

<protected> _stringToArray(input)

Safe transform of a String into an Array

Parameters:
Name Type Description
input String
Source:
Returns:

null if 'input == null', [] if 'input == ""', 'input' if its content didn't allow to create an Array

Type
Array

<protected> _stringToObject(input)

Safe transform of a String into an Object

Parameters:
Name Type Description
input String
Source:
Returns:

null if 'input == null', {} if 'input == ""', 'input' if its content didn't allow to create an Object

Type
Array

debug(req)

Check the status of the debug flag

Parameters:
Name Type Description
req Request
Source:
Returns:
Type
boolean

getKey()

Get this RequestHandler's key

Source:
Returns:
Type
String

getMiddleware( [action] [, options])

Returns the Handler for a request
Default implementation returns a middleware that does nothing and calls next()

Parameters:
Name Type Argument Description
action String <optional>

to be used to redirect the request

options Object <optional>

to be passed to the requested middleware

Source:

<protected> getSession()

Safe generic getter of session response or request object

Source:

<protected> getSessionRequest()

Safe getter of session request object

Source:

<protected> getSessionResponse()

Safe getter of session response object

Source:

<protected> initMessages()

Create the objects to hold flash messages if needed.

Source:

<protected> setErrorMessage()

Saves an error message

Source:

<protected> setInfoMessage()

Saves an info message

Source:

<protected> setMessage()

Saves a message in the Session message holder

Source:

<protected> setSession()

Safe generic setter of session response or request object

Source:

<protected> setSessionRequest()

Safe setter of session request object

Source:

<protected> setSessionResponse()

Safe setter of session response object

Source:

<protected> setSuccessMessage()

Saves a success message

Source:

<protected> setWarningMessage()

Saves a warning message

Source: