Global

Methods

_ERROR(err, options) → {string}

Creates a formatted error response message and converts to XML

Parameters:
Name Type Description
err *

Error data to be included in error response. If err is an instanceof Error or has a .message property it is assumed that the .message property is the only thing to include in error response

options Object

Configurable options for error XML formatting

Properties
Name Type Attributes Default Description
skip_conversion Boolean <optional>
this.skip_conversion

If true rendering is skipped and the data argument is immediately returned

xml_root string <optional>
this.xml_root

Defines the value of the XML document root tag. If this.xml_root is not set and options.xml_root is not provided a TypeError will be thrown

xml_configuration Object

Options for the convert function see js2xmlparser documentation for full details

Source:
Returns:

Returns the rendered XML string or the err argument if options.skip_conversion is true

Type
string

_ERROR(err, options) → {Object}

Creates a formatted error response object

Parameters:
Name Type Description
err *

Any data to be sent as part of error response

options Object

Configurable options for error response formatting

Properties
Name Type Attributes Default Description
formatError function <optional>
this.formatError

Custom formatting function for json error response. This argument will be ignored if not a function

Source:
Returns:

Formatted error response object

Type
Object

_ERROR(err, options, cb)

Renders an HTML error page template

Parameters:
Name Type Description
err Object

If err is an instanceof Error or has a .message property only the error message will be included

options Object

Configurable options for error template rendering see _RENDER for further details on options

Properties
Name Type Attributes Default Description
viewname string <optional>
"home/error404"

Overrideable view name for the error template

cb function

Callback function

Source:

_RENDER(data, options) → {string}

Creates a formatted success message and converts to XML

Parameters:
Name Type Description
data *

Any data to be included in XML response

options Object

Configurable options for XML response generation

Properties
Name Type Attributes Default Description
skip_conversion Boolean <optional>
this.skip_conversion

If true rendering is skipped and the data argument is immediately returned

xml_root string <optional>
this.xml_root

Defines the value of the XML document root tag. If this.xml_root is not set and options.xml_root is not provided a TypeError will be thrown

xml_configuration Object <optional>
this.xml_configuration

Options for the convert function see js2xmlparser documentation for full details

Source:
Returns:

Returns the rendered XML string or the data argument if options.skip_conversion is true

Type
string

_RENDER(data, options) → {Object}

Creates a formatted success response object

Parameters:
Name Type Description
data *

Any data that should be sent with the success response

options Object

Configurable options for success response formatting

Properties
Name Type Attributes Default Description
formatRender function <optional>
this.formatRender

Custom formatting function for json success response. This argument will be ignored if not a function

Source:
Returns:

Formatted success response object

Type
Object

_RENDER(data, options, cb)

Renders an HTML string from provided data

Parameters:
Name Type Description
data Object

Template data should conform to EJS template by default or custom templating engine

options Object

Configurable options for the rendering of HTML string

Properties
Name Type Attributes Default Description
themename string <optional>
this.themename

Specifies a periodic theme folder that will be checked when looking for a matching template

viewname string <optional>
this.viewname

Specifies the filename of the template

extname string <optional>
this.extname

Specifies a periodicjs extension folder that should be checked when looking for a matching template

resolve_filepath Boolean <optional>

If true a valid file path will be returned and rendering of the template file will be skipped

fileext string <optional>
this.fileext

Specifies the extension name of the template file

dirname string | Array.<string> <optional>

Optional custom directories to be checked for template

engine_configuration Object <optional>
this.engine_configuration

Custom configuration object for whichever templating engine being used see EJS documentation for details on options for EJS

cb function

Callback function

Source:

findValidViewFromPaths(_default, dirsopt) → {Object}

Iterates through an array of file paths resolving after it finds a valid path or resolves with the default value

Parameters:
Name Type Attributes Default Description
_default string

A default value to resolve if no provided file path is valid

dirs Array.<string> <optional>
[]

File paths to check for validity (file exists)

Source:
Returns:

Returns a Promise which resolves with a file path or the default value

Type
Object