mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
26 lines
726 B
JavaScript
26 lines
726 B
JavaScript
const GROUPS = new Set([
|
|
'stations',
|
|
'visual',
|
|
'gps-ops',
|
|
'glo-ops',
|
|
'galileo',
|
|
'geo',
|
|
'starlink',
|
|
]);
|
|
|
|
/** Read catalog text from the existing group endpoint using a supplied transport. */
|
|
export function createSatelliteSource({
|
|
fetchImpl = (...args) => globalThis.fetch(...args),
|
|
} = {}) {
|
|
return {
|
|
async readGroup(group, { signal } = {}) {
|
|
if (!GROUPS.has(group)) throw new TypeError('Unknown satellite group');
|
|
signal?.throwIfAborted();
|
|
const response = await fetchImpl(`/api/celestrak/${group}`, { signal });
|
|
const text = response.ok ? await response.text() : '';
|
|
signal?.throwIfAborted();
|
|
return { ok: response.ok, status: response.status, text };
|
|
},
|
|
};
|
|
}
|