Return fallback image when remote server returns 404#355
Merged
eduardoboucas merged 5 commits intodevelopfrom May 10, 2018
Merged
Return fallback image when remote server returns 404#355eduardoboucas merged 5 commits intodevelopfrom
eduardoboucas merged 5 commits intodevelopfrom
Conversation
eduardoboucas
approved these changes
May 10, 2018
| let address = this.address() | ||
| let env = config.get('env') | ||
|
|
||
| /* istanbul ignore next */ |
|
|
||
| return reject(err) | ||
| if (err.statusCode === 404) { | ||
| return new Missing().get().then(stream => { |
Contributor
There was a problem hiding this comment.
I personally tend to not create Promise constructs when already inside one, which would allow you to get rid of the catch:
return resolve(
new Missing().get().then(stream => {
this.notFound = true
this.lastModified = new Date()
return stream
})
)But this one is really just a matter of personal taste, so more than happy for it to stay as it is!
| @@ -1,21 +1,22 @@ | |||
| var AWS = require('aws-sdk-mock') | |||
Contributor
There was a problem hiding this comment.
Did you mean to set this one as var?
| client | ||
| .get('/jpg/50/0/0/801/478/0/0/0/2/aspectfit/North/0/0/0/0/0/testxxx.jpg') | ||
| .end(function (err, res) { | ||
| let isBuffer = (res.body instanceof Buffer) |
Contributor
There was a problem hiding this comment.
Could this be just res.body.should.be.instanceof(Buffer)? 🤔
Contributor
Author
There was a problem hiding this comment.
I knew there was a better way!
| let address = this.address() | ||
| let env = config.get('env') | ||
|
|
||
| /* istanbul ignore next */ |
| var address = this.address() | ||
| let env = config.get('env') | ||
|
|
||
| /* istanbul ignore next */ |
|
|
||
| [](https://www.npmjs.com/package/@dadi/cdn) | ||
| [](https://github.com/dadi/cdn) | ||
| [](https://github.com/dadi/cdn) |
Contributor
There was a problem hiding this comment.
This makes me so happy!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replicates the functionality of S3 and Disk storage where, if configured, a fallback image is returned to the consumer instead if just a JSON message.
Close #353