Skip to content

Commit a53a585

Browse files
chore: code formatting
1 parent 13a071e commit a53a585

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

source/plugins/community/crypto/index.mjs

+23-27
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,64 @@ export default async function({login, q, imports, data, account}, {enabled = fal
66
if ((!q.crypto) || (!imports.metadata.plugins.crypto.enabled(enabled, {extras})))
77
return null
88

9-
//Load inputs
10-
let {id, days, vs_currency, precision } = imports.metadata.plugins.crypto.inputs({data, account, q})
9+
//Load inputs
10+
let {id, days, vs_currency, precision} = imports.metadata.plugins.crypto.inputs({data, account, q})
1111
if (!id)
12-
throw { error: { message: "Crypto currency id is not set" } }
12+
throw {error: {message: "Crypto currency id is not set"}}
1313

1414
console.debug(`metrics/compute/${login}/plugins > crypto > querying api for crypto`)
1515

1616
const {
17-
data: coin
18-
} = await imports.axios.get(`https://api.coingecko.com/api/v3/coins/${id}`,
19-
{
20-
params: {
21-
market_data:true
22-
}
23-
})
17+
data: coin,
18+
} = await imports.axios.get(`https://api.coingecko.com/api/v3/coins/${id}`, {
19+
params: {
20+
market_data: true,
21+
},
22+
})
2423

25-
if (!coin) {
24+
if (!coin)
2625
throw {error: {message: "Crypto currency not found"}}
27-
}
2826

2927
const {
30-
data: { prices },
31-
} = await imports.axios.get(`https://api.coingecko.com/api/v3/coins/${id}/market_chart`, {
28+
data: {prices},
29+
} = await imports.axios.get(`https://api.coingecko.com/api/v3/coins/${id}/market_chart`, {
3230
params: {
33-
vs_currency,
34-
days,
35-
precision
31+
vs_currency,
32+
days,
33+
precision,
3634
},
37-
})
38-
35+
})
3936

4037
const chart = imports.Graph.timeline(
41-
prices.map((y, _) => ({ x: new Date(y[0]), y: y[1] })),
38+
prices.map((y, _) => ({x: new Date(y[0]), y: y[1]})),
4239
{
4340
low: Math.min(...prices.map((y, _) => y[1])),
4441

4542
high: Math.max(...prices.map((y, _) => y[1])),
4643

47-
points: false, text: false,
44+
points: false,
45+
text: false,
4846
width: 480 * (1 + data.large),
49-
height: 200
50-
}
47+
height: 200,
48+
},
5149
)
5250

53-
5451
//Results
5552
return {
5653
chart,
5754
id,
5855
precision,
59-
days:{"1":"Today", "14":"2 Weeks", "30":"1 Month", max :"All-time"}[days],
56+
days: {"1": "Today", "14": "2 Weeks", "30": "1 Month", max: "All-time"}[days],
6057
symbol: coin.symbol,
6158
name: coin.name,
6259
current_price: coin.market_data.current_price[vs_currency],
6360
price_change_percentage_24h: coin.market_data.price_change_percentage_24h,
6461
vs_currency,
65-
logo:coin.image.small,
62+
logo: coin.image.small,
6663
}
6764
}
6865
//Handle errors
6966
catch (error) {
7067
throw imports.format.error(error)
7168
}
7269
}
73-

0 commit comments

Comments
 (0)