diff --git a/ghost/core/core/server/api/endpoints/oembed.js b/ghost/core/core/server/api/endpoints/oembed.js index f9ac28de36..1031ba9e84 100644 --- a/ghost/core/core/server/api/endpoints/oembed.js +++ b/ghost/core/core/server/api/endpoints/oembed.js @@ -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', diff --git a/ghost/core/core/server/services/oembed/index.js b/ghost/core/core/server/services/oembed/index.js new file mode 100644 index 0000000000..102ef66d4f --- /dev/null +++ b/ghost/core/core/server/services/oembed/index.js @@ -0,0 +1 @@ +module.exports = require('./service'); diff --git a/ghost/core/core/server/services/nft-oembed.js b/ghost/core/core/server/services/oembed/nft-oembed.js similarity index 100% rename from ghost/core/core/server/services/nft-oembed.js rename to ghost/core/core/server/services/oembed/nft-oembed.js diff --git a/ghost/core/core/server/services/oembed/service.js b/ghost/core/core/server/services/oembed/service.js new file mode 100644 index 0000000000..6e44bf9344 --- /dev/null +++ b/ghost/core/core/server/services/oembed/service.js @@ -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; diff --git a/ghost/core/core/server/services/twitter-embed.js b/ghost/core/core/server/services/oembed/twitter-embed.js similarity index 100% rename from ghost/core/core/server/services/twitter-embed.js rename to ghost/core/core/server/services/oembed/twitter-embed.js diff --git a/ghost/core/test/unit/server/services/nft-oembed.test.js b/ghost/core/test/unit/server/services/oembed/nft-oembed.test.js similarity index 86% rename from ghost/core/test/unit/server/services/nft-oembed.test.js rename to ghost/core/test/unit/server/services/oembed/nft-oembed.test.js index 1c68242a90..1ccf6d0088 100644 --- a/ghost/core/test/unit/server/services/nft-oembed.test.js +++ b/ghost/core/test/unit/server/services/oembed/nft-oembed.test.js @@ -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 () {