-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Remove Unsplash; Add Lorem Flickr and Lorem Picsum
- Loading branch information
1 parent
d822eaa
commit bbaef53
Showing
4 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
|
||
const providers = { | ||
'custom-v1': require('./custom-v1'), | ||
s3: require('./s3'), | ||
unsplash: require('./unsplash') | ||
} | ||
"custom-v1": require("./custom-v1"), | ||
s3: require("./s3"), | ||
"lorem-flickr": require("./lorem-flickr"), | ||
picsum: require("./picsum"), | ||
unsplash: require("./unsplash"), | ||
}; | ||
|
||
module.exports = { | ||
providers, | ||
defaultableProviders: Object.keys(providers).filter(providerName => providers[providerName].defaultable) | ||
} | ||
providers, | ||
defaultableProviders: Object.keys(providers).filter( | ||
(providerName) => providers[providerName].defaultable, | ||
), | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const BaseProvider = require("./base-provider"); | ||
|
||
class LoremFlickr extends BaseProvider { | ||
constructor(provider) { | ||
super(provider); | ||
this._defaultResponseBody.provider = "LoremFlickr"; | ||
this._defaultResponseBody.license = "Creative Commons"; | ||
this._defaultResponseBody.terms = "https://loremflickr.com/"; | ||
} | ||
|
||
static get defaultable() { | ||
return true; | ||
} | ||
|
||
randomImage(query) { | ||
const height = query.size.height || 1080; | ||
const width = query.size.width || 1920; | ||
return fetch( | ||
`https://loremflickr.com/${width}/${height}/${query.category}`, | ||
).then((res) => | ||
this._normalizeResponse({ | ||
url: res.url, | ||
size: { height, width }, | ||
}), | ||
); | ||
} | ||
} | ||
|
||
module.exports = LoremFlickr; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const BaseProvider = require("./base-provider"); | ||
|
||
class Picsum extends BaseProvider { | ||
constructor(provider) { | ||
super(provider); | ||
this._defaultResponseBody.provider = "LoremPicsum"; | ||
this._defaultResponseBody.license = "CC0"; | ||
this._defaultResponseBody.terms = "https://picsum.photos/"; | ||
} | ||
|
||
static get defaultable() { | ||
return true; | ||
} | ||
|
||
randomImage(query) { | ||
const height = query.size.height || 1080; | ||
const width = query.size.width || 1920; | ||
return fetch(`https://picsum.photos/${width}/${height}`).then((res) => | ||
this._normalizeResponse({ | ||
url: res.url, | ||
size: { height, width }, | ||
}), | ||
); | ||
} | ||
} | ||
|
||
module.exports = Picsum; |
This file contains 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