/provider/cloudfront

The cloudfront provider module exports a method to fetch resources from an AWS cloudfront service.

The fetch requests and their status can be logged with the 'cloudfront' log.

The provider module requires the cloudfront signer which requires a cloudfront key. If not provided the module will export null.

Requires

Methods

(inner) cloudfront(req) → {function}

The cloudfront method returns an async Fetch method which must be awaited to resolve into a cloudfront resource.

A req param will be provided by requests through the provider endpoint module.

The req param is string if the request for a resource is passed from the getFrom module.

Parameters:
NameTypeDescription
reqreq | string

Request object or URL string.

Properties
NameTypeAttributesDescription
req.paramsobject<optional>

Request params.

params.urlstring

URL in request param.

Returns:

The async fetch function is returned.

Type: 
function

(async, inner) fetch(url) → {Promise.<(String|JSON|Error)>}

The url string is passed to the cloudfront signer to request a signed URL.

The resource is fetched from the signed cloudfront URL.

The response is parsed as JSON if the URL ending matches .json

Parameters:
NameTypeDescription
urlstring

Cloudfront resource URL.

Returns:

The fetch is resolved into either a string or JSON depending on the url ending.

Type: 
Promise.<(String|JSON|Error)>