29 lines
917 B
JavaScript
Raw Permalink Normal View History

2025-10-30 15:00:06 +01:00
const API_PREFIX = '/api/v1';
2025-10-17 14:46:44 +02:00
const joinUrl = (...parts) => parts.join('/').replace(/\/{2,}/g, '/');
const encodeHash = (hash) => encodeURIComponent(String(hash));
2025-10-17 14:46:44 +02:00
2025-10-20 15:42:12 +02:00
const HEALTH_ENDPOINT = joinUrl(API_PREFIX, 'health/stream');
2025-10-17 14:46:44 +02:00
const TRANSACTION_DETAIL_BY_HASH = (hash) => joinUrl(API_PREFIX, 'transactions', encodeHash(hash));
2025-10-20 15:42:12 +02:00
const TRANSACTIONS_STREAM = joinUrl(API_PREFIX, 'transactions/stream');
const BLOCK_DETAIL_BY_HASH = (hash) => joinUrl(API_PREFIX, 'blocks', encodeHash(hash));
2025-10-20 15:42:12 +02:00
const BLOCKS_STREAM = joinUrl(API_PREFIX, 'blocks/stream');
export const API = {
HEALTH_ENDPOINT,
TRANSACTION_DETAIL_BY_HASH,
2025-10-20 15:42:12 +02:00
TRANSACTIONS_STREAM,
BLOCK_DETAIL_BY_HASH,
2025-10-20 15:42:12 +02:00
BLOCKS_STREAM,
};
const BLOCK_DETAIL = (hash) => joinUrl('/blocks', encodeHash(hash));
const TRANSACTION_DETAIL = (hash) => joinUrl('/transactions', encodeHash(hash));
2025-10-17 14:46:44 +02:00
2025-10-20 15:42:12 +02:00
export const PAGE = {
BLOCK_DETAIL,
TRANSACTION_DETAIL,
};