RouterResponse

Provides AWS CloudFront response instance and methods.

Constructor

new RouterResponse(cfResObj)

Parameters:
NameTypeDescription
cfResObjCloudFrontResponse | undefined

CloudFront response object (optional).

Methods

data() → {CloudFrontResponse}

Return the CloudFront response data.

Returns:
Type: 
CloudFrontResponse

json(data) → {String}

Return the data as JSON.

Parameters:
NameTypeDescription
dataObject

Data as object.

Returns:
Type: 
String

setHeader(key, value)

Set HTTP response header.

Parameters:
NameTypeDescription
keyString

HTTP header key.

valueString

HTTP header value.

Example
res.setHeader('Content-Type', 'text/html');

status(code) → {Object.<function()>}

Return the AWS response data.

Parameters:
NameTypeDescription
codeNumber

HTTP status code.

Returns:
Type: 
Object.<function()>
Example
res.setHeader('Content-Type', 'mime/type');
res.status(200).send(value);
  ..

res.setHeader('Content-Type', 'application/json');
res.status(200).json({hello: 'world'});
  ..

res.setHeader('Content-Type', 'text/html');
res.status(200).text('Hello World');
  ..

res.setHeader('Content-Type', 'image/jpeg; charset=utf-8');
res.status(200).data(buffer);

text(body) → {String}

Return the body text.

Parameters:
NameTypeDescription
bodyString

Body as string.

Returns:
Type: 
String