MCPcopy Create free account
hub / github.com/EvoMap/evolver / _hubGet

Function _hubGet

src/atp/hubClient.js:122–144  ·  view source on GitHub ↗
(pathSuffix, timeoutMs)

Source from the content-addressed store, hash-verified

120}
121
122function _hubGet(pathSuffix, timeoutMs) {
123 const hubUrl = getHubUrl();
124 if (!hubUrl) return Promise.resolve({ ok: false, error: 'no_hub_url' });
125 const endpoint = hubUrl.replace(/\/+$/, '') + pathSuffix;
126 const timeout = timeoutMs || require('../config').HTTP_TRANSPORT_TIMEOUT_MS;
127 const buildHeaders = buildNodeScopedHubHeaders || buildHubHeaders;
128 return hubFetch(endpoint, {
129 method: 'GET',
130 headers: buildHeaders(),
131 signal: AbortSignal.timeout(timeout),
132 })
133 .then(function (res) {
134 if (!res.ok) return res.text().then(function (t) { return { ok: false, status: res.status, error: t.slice(0, 400) }; });
135 return res.json().then(function (data) { return { ok: true, data: data }; });
136 })
137 .catch(function (err) {
138 const msg = (err && err.message) || String(err);
139 if (msg.indexOf('[hubFetch]') !== -1) {
140 return { ok: false, error: 'tls_refused: ' + msg };
141 }
142 return { ok: false, error: msg };
143 });
144}
145
146// Dispatcher: choose proxy or direct hub based on env + proxy availability.
147// proxyPath is the path relative to proxy root (e.g. '/atp/order').

Callers 2

_getFunction · 0.85
listMyTasksFunction · 0.85

Calls 1

getHubUrlFunction · 0.85

Tested by

no test coverage detected