-
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: Server handlers aecoin (#1044)
- Loading branch information
Showing
9 changed files
with
149 additions
and
156 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
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
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
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
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
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,86 +1,17 @@ | ||
import cache from 'memory-cache' | ||
import { | ||
CACHE_KEY_COINSTORE_MARKET_DATA, | ||
CACHE_KEY_COINW_MARKET_DATA, | ||
CACHE_KEY_GATE_MARKET_DATA, | ||
CACHE_KEY_HOTCOIN_MARKET_DATA, | ||
CACHE_KEY_MEXC_MARKET_DATA, | ||
MARKET_STATS_CACHE_TTL, | ||
MARKET_STATS_COINSTORE_ADDRESS, | ||
MARKET_STATS_HOTCOIN_ADDRESS, | ||
} from '@/utils/constants' | ||
|
||
export const useAeCoinStore = defineStore('aeCoin', () => { | ||
const axios = useAxios() | ||
|
||
const gate = ref(null) | ||
const mexc = ref(null) | ||
const hotCoin = ref(null) | ||
const coinStore = ref(null) | ||
const coinW = ref(null) | ||
|
||
const coinMarkets = ref(null) | ||
const isLoading = ref(true) | ||
|
||
function fetchMarketStats() { | ||
async function fetchMarketStats() { | ||
isLoading.value = true | ||
return Promise.allSettled([ | ||
fetchGate(), | ||
fetchMexc(), | ||
fetchHotCoin(), | ||
fetchCoinStore(), | ||
fetchCoinW(), | ||
]).then(() => { | ||
isLoading.value = false | ||
}) | ||
} | ||
|
||
async function fetchGate() { | ||
if (!cache.get(CACHE_KEY_GATE_MARKET_DATA)) { | ||
const { data } = await axios.get('/proxy/gate') | ||
cache.put(CACHE_KEY_GATE_MARKET_DATA, adaptMarketStatsGate(data), MARKET_STATS_CACHE_TTL) | ||
} | ||
gate.value = cache.get(CACHE_KEY_GATE_MARKET_DATA) | ||
} | ||
|
||
async function fetchMexc() { | ||
if (!cache.get(CACHE_KEY_MEXC_MARKET_DATA)) { | ||
const { data } = await axios.get('/proxy/mexc') | ||
cache.put(CACHE_KEY_MEXC_MARKET_DATA, adaptMarketStatsMexc(data), MARKET_STATS_CACHE_TTL) | ||
} | ||
mexc.value = cache.get(CACHE_KEY_MEXC_MARKET_DATA) | ||
} | ||
|
||
async function fetchCoinStore() { | ||
if (!cache.get(CACHE_KEY_COINSTORE_MARKET_DATA)) { | ||
const { data } = await axios.get(MARKET_STATS_COINSTORE_ADDRESS) | ||
cache.put(CACHE_KEY_COINSTORE_MARKET_DATA, adaptMarketStatsCoinStore(data), MARKET_STATS_CACHE_TTL) | ||
} | ||
coinStore.value = cache.get(CACHE_KEY_COINSTORE_MARKET_DATA) | ||
} | ||
|
||
async function fetchHotCoin() { | ||
if (!cache.get(CACHE_KEY_HOTCOIN_MARKET_DATA)) { | ||
const { data } = await axios.get(MARKET_STATS_HOTCOIN_ADDRESS) | ||
cache.put(CACHE_KEY_HOTCOIN_MARKET_DATA, adaptMarketStatsHotCoin(data), MARKET_STATS_CACHE_TTL) | ||
} | ||
hotCoin.value = cache.get(CACHE_KEY_HOTCOIN_MARKET_DATA) | ||
} | ||
|
||
async function fetchCoinW() { | ||
if (!cache.get(CACHE_KEY_COINW_MARKET_DATA)) { | ||
const { data } = await axios.get('/proxy/coinw') | ||
cache.put(CACHE_KEY_COINW_MARKET_DATA, adaptMarketStatsCoinW(data), MARKET_STATS_CACHE_TTL) | ||
} | ||
coinW.value = cache.get(CACHE_KEY_COINW_MARKET_DATA) | ||
const data = await $fetch('/api/tokens/ae') | ||
coinMarkets.value = data | ||
isLoading.value = false | ||
} | ||
|
||
return { | ||
gate, | ||
mexc, | ||
hotCoin, | ||
coinStore, | ||
coinW, | ||
isLoading, | ||
coinMarkets, | ||
fetchMarketStats, | ||
} | ||
}) |
File renamed without changes.
Oops, something went wrong.