/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.
- Source
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.
Name | Type | Description |
---|---|---|
req | req | | Request object or URL string. |
Name | Type | Attributes | Description |
---|---|---|---|
req.params | object | <optional> | Request params. |
params.url | string | URL in request param. |
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
Name | Type | Description |
---|---|---|
url | string | Cloudfront resource URL. |
The fetch is resolved into either a string or JSON depending on the url ending.
- Type:
- Promise.<(String|JSON|Error)>