From 05e6803e107f0ea3825b51ae4638d6cbcfb3a751 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 20 May 2024 12:29:57 +0300 Subject: [PATCH] TW-1456: Limit DApps list for iOS (#158) --- src/getDAppsStats.ts | 6 ++--- src/index.ts | 10 +++++--- src/utils/dapp-list-constants.ts | 39 ++++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/getDAppsStats.ts b/src/getDAppsStats.ts index cd38b16..9b7115e 100644 --- a/src/getDAppsStats.ts +++ b/src/getDAppsStats.ts @@ -1,11 +1,11 @@ -import { dappList } from './utils/dapp-list-constants'; +import { DAPPS_LIST, IOS_DAPPS_LIST } from './utils/dapp-list-constants'; import logger from './utils/logger'; -const getDAppsStats = async () => { +const getDAppsStats = (forIOs: boolean) => { logger.info('Getting dApps list...'); return { - dApps: dappList + dApps: forIOs ? IOS_DAPPS_LIST : DAPPS_LIST }; }; diff --git a/src/index.ts b/src/index.ts index 9938eb9..80d4f01 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,8 +66,6 @@ app.use(pinoHttp(PINO_LOGGER)); app.use(cors()); app.use(bodyParser.json()); -const dAppsProvider = new SingleQueryDataProvider(15 * 60 * 1000, getDAppsStats); - const androidApp = firebaseAdmin.initializeApp( { projectId: 'templewallet-fa3b3' @@ -162,7 +160,13 @@ app.post('/api/notifications', basicAuth, async (req, res) => { } }); -app.get('/api/dapps', makeProviderDataRequestHandler(dAppsProvider)); +app.get('/api/dapps', (req, res) => { + const platform = req.query.platform; + + const data = getDAppsStats(platform === 'ios'); + + res.status(200).header('Cache-Control', 'public, max-age=300').send(data); +}); app.get('/api/abtest', (_, res) => { const data = getABData(); diff --git a/src/utils/dapp-list-constants.ts b/src/utils/dapp-list-constants.ts index 752588b..90e17bb 100644 --- a/src/utils/dapp-list-constants.ts +++ b/src/utils/dapp-list-constants.ts @@ -1,4 +1,4 @@ -interface DappList { +interface DappListItem { name: string; dappUrl: string; type: DappType; @@ -16,7 +16,7 @@ enum DappType { Other = 'Other' } -export const dappList: DappList[] = [ +export const DAPPS_LIST: DappListItem[] = [ { name: 'QuipuSwap', dappUrl: 'https://quipuswap.com', @@ -154,3 +154,38 @@ export const dappList: DappList[] = [ categories: [DappType.DeFi] } ]; + +export const IOS_DAPPS_LIST: DappListItem[] = [ + { + name: 'Tezos Projects', + dappUrl: 'https://ecosystem.tezos.com', + logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/tezos.png', + slug: 'ecosystem.tezos.com', + type: DappType.Other, + categories: [] + }, + { + name: 'Mad.Fish', + dappUrl: 'https://mad.fish/products', + logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/madfish.png', + slug: 'mad.fish/products', + type: DappType.Other, + categories: [] + }, + { + name: 'Temple Wallet', + dappUrl: 'https://templewallet.com/download?platform=extension', + logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/temple.png', + slug: 'download-tw-extension', + type: DappType.Other, + categories: [] + }, + { + name: 'TZKT', + dappUrl: 'https://tzkt.io/dapps', + logo: 'https://temple-wallet-stage-bucket.nyc3.cdn.digitaloceanspaces.com/dapps/tzkt.png', + slug: 'tzkt.io/dapps', + type: DappType.Other, + categories: [] + } +];