Class: HTTP_ADAPTER

HTTP_ADAPTER

A protocol adapter for HTTP requests and responses

Constructor

new HTTP_ADAPTER(options)

Constructor for HTTP_Adapter

Parameters:
Name Type Description
options Object

Options for the HTTP adapter

Properties
Name Type Attributes Default Description
db Object

Database adapters indexed by model name (periodicjs.core.data)

express Object

Express module

responder Object

A response adapter (periodicjs.core.responder)

config Object

Periodic configuration object

settings Object

Periodic application settings

resources Object

Periodic resources

api string

Name of the api adapter that should be used

logger Object <optional>
console

A logger module

Source:

Methods

error(req, res, optionsopt) → {Object}

Handles logging errors

Parameters:
Name Type Attributes Default Description
req Object

Express request object

res Object

Express response object

options Object <optional>
{}

Configurable options for error logging

Properties
Name Type Description
err Object

An error to log

Source:
Returns:

this

Type
Object

exception(req, res, optionsopt) → {Object}

Handles sending an error response

Parameters:
Name Type Attributes Default Description
req Object

Express request object

res Object

Express response object

options Object <optional>
{}

Configurable options for error logging

Properties
Name Type Description
err Object

An error to log. If this.config.exception_message is set error param is ignored

Source:
Returns:

this

Type
Object

implement(options) → {Object}

Convenience method for accessing .implement method on API adapter. Also handles implementing controllers and routers for multiple models

Parameters:
Name Type Description
options Object

Configurable options for implementing controllers and routers. See API adapter .implement method for more details

Properties
Name Type Description
model_name string | Array.<string>

An array of model names or a single model name that should have controllers and routes implemented

Source:
Returns:

this

Type
Object

redirect(req, res, optionsopt) → {Object}

Handles redirects

Parameters:
Name Type Attributes Default Description
req Object

Express request object

res Object

Express response object

options Object <optional>
{}

Configurable options for redirect

Properties
Name Type Description
model_name string

A path to attempt for redirect if req.redirect is not provided

Source:
Returns:

this

Type
Object

respond(req, res, optionsopt) → {Object}

Handles sending the response to a request by rendering data according to this.responder configuration

Parameters:
Name Type Attributes Default Description
req Object

Express request object

res Object

Express response object

options Object <optional>
{}

Configurable options for response

Properties
Name Type Description
ignore_error Boolean

If true error will be treated like a normal response

return_response_data Boolean

If true respond will not send HTTP response and will instead return rendered data

responder_override *

Data to send in response. If this value is defined A success response will always be set and all formatting rules will be ignored

skip_default_props Boolean

If true request details will not be appended to success response

err Object

An error to send in response. If this value is set an error response will be generated unless options.ignore_error is true

data Object

Data to send in success response. If options.err is defined this value will be ignored

Source:
Returns:

this

Type
Object

warn(req, res, optionsopt) → {Object}

Handles logging warns

Parameters:
Name Type Attributes Default Description
req Object

Express request object

res Object

Express response object

options Object <optional>
{}

Configurable options for warning logging

Properties
Name Type Description
err Object

An error to log

Source:
Returns:

this

Type
Object