mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Refactored OEmbed service into a proper service
This allows us to share the implementation with other parts of the codebase, the specific usecase here being fetching the metadata from webmention sources, for display in the mentions UI, which will be borrowing a lot of stuff from the bookmark card.
This commit is contained in:
parent
a7eeb8f628
commit
d0d45d45bc
@ -1,25 +1,4 @@
|
||||
const config = require('../../../shared/config');
|
||||
const externalRequest = require('../../lib/request-external');
|
||||
|
||||
const OEmbed = require('@tryghost/oembed-service');
|
||||
const oembed = new OEmbed({config, externalRequest});
|
||||
|
||||
const NFT = require('../../services/nft-oembed');
|
||||
const nft = new NFT({
|
||||
config: {
|
||||
apiKey: config.get('opensea').privateReadOnlyApiKey
|
||||
}
|
||||
});
|
||||
|
||||
const Twitter = require('../../services/twitter-embed');
|
||||
const twitter = new Twitter({
|
||||
config: {
|
||||
bearerToken: config.get('twitter').privateReadOnlyToken
|
||||
}
|
||||
});
|
||||
|
||||
oembed.registerProvider(nft);
|
||||
oembed.registerProvider(twitter);
|
||||
const oembed = require('../../services/oembed');
|
||||
|
||||
module.exports = {
|
||||
docName: 'oembed',
|
||||
|
1
ghost/core/core/server/services/oembed/index.js
Normal file
1
ghost/core/core/server/services/oembed/index.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./service');
|
24
ghost/core/core/server/services/oembed/service.js
Normal file
24
ghost/core/core/server/services/oembed/service.js
Normal file
@ -0,0 +1,24 @@
|
||||
const config = require('../../../shared/config');
|
||||
const externalRequest = require('../../lib/request-external');
|
||||
|
||||
const OEmbed = require('@tryghost/oembed-service');
|
||||
const oembed = new OEmbed({config, externalRequest});
|
||||
|
||||
const NFT = require('./nft-oembed');
|
||||
const nft = new NFT({
|
||||
config: {
|
||||
apiKey: config.get('opensea').privateReadOnlyApiKey
|
||||
}
|
||||
});
|
||||
|
||||
const Twitter = require('./twitter-embed');
|
||||
const twitter = new Twitter({
|
||||
config: {
|
||||
bearerToken: config.get('twitter').privateReadOnlyToken
|
||||
}
|
||||
});
|
||||
|
||||
oembed.registerProvider(nft);
|
||||
oembed.registerProvider(twitter);
|
||||
|
||||
module.exports = oembed;
|
@ -1,5 +1,5 @@
|
||||
const assert = require('assert');
|
||||
const NFTOembedProvider = require('../../../../core/server/services/nft-oembed');
|
||||
const NFTOembedProvider = require('../../../../../core/server/services/oembed/nft-oembed');
|
||||
|
||||
describe('NFTOEmbedProvider', function () {
|
||||
it('Can support requests for OpenSea Ethereum NTFs', async function () {
|
Loading…
Reference in New Issue
Block a user