Skip to content

Commit 9193e20

Browse files
committed
refactor(response/{bybit,coinbase}/aggregate.mjs): use method successfulJson
1 parent f8c0e41 commit 9193e20

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

response/bybit/aggregate.mjs

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* @module response/bybit/aggregate
66
*/
77

8+
import { successfulJson } from '#lib/fetch.mjs';
89
import { fileReadJson } from '#lib/file_system.mjs';
910

1011
import aggregate from '../aggregate.mjs';
@@ -18,12 +19,12 @@ import aggregate from '../aggregate.mjs';
1819
const bybitAggregate = (directory, fileName) => {
1920
const { bybit } = global.apiTools,
2021
endpoint = directory.toUpperCase(),
21-
json = fileReadJson('response/bybit/snapshot/' + directory, fileName),
22-
data = json.CREATED?.json || json.OK?.json.result.rows,
22+
fileData = fileReadJson('response/bybit/snapshot/' + directory, fileName),
23+
json = /** @type {{ result: { rows: object }}} */ (successfulJson(fileData)).result.rows,
2324
file = aggregate(
2425
bybit,
2526
endpoint,
26-
data,
27+
json,
2728
{
2829
currencies: (item) => ({
2930
chains: item.chains.map((item) => ({

response/coinbase/aggregate.mjs

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* @module response/coinbase/aggregate
66
*/
77

8+
import { successfulJson } from '#lib/fetch.mjs';
89
import { fileReadJson } from '#lib/file_system.mjs';
910

1011
import aggregate from '../aggregate.mjs';
@@ -18,12 +19,12 @@ import aggregate from '../aggregate.mjs';
1819
const coinbaseAggregate = (directory, fileName) => {
1920
const { coinbase } = global.apiTools,
2021
endpoint = directory.toUpperCase(),
21-
json = fileReadJson('response/coinbase/snapshot/' + directory, fileName),
22-
data = json.CREATED?.json || json.OK?.json.data,
22+
fileData = fileReadJson('response/coinbase/snapshot/' + directory, fileName),
23+
json = /** @type {{ data: object }} */ (successfulJson(fileData)).data,
2324
file = aggregate(
2425
coinbase,
2526
endpoint,
26-
data,
27+
json,
2728
{
2829
currencies: (item) => ({
2930
asset_id: item['asset_id'],

0 commit comments

Comments
 (0)