MCPcopy
hub / github.com/lissy93/web-check / upstreamError

Function upstreamError

api/_common/upstream.js:2–12  ·  view source on GitHub ↗
(error, context = 'Lookup')

Source from the content-addressed store, hash-verified

1// Map axios/network errors to our shared envelope shape
2export const upstreamError = (error, context = 'Lookup') => {
3 const status = error.response?.status;
4 if (status === 404 || status === 410) return { skipped: `No ${context} data for this host` };
5 if (status === 401 || status === 403) return { error: `${context} blocked (HTTP ${status})` };
6 if (status === 429) return { error: `${context} rate-limited by upstream` };
7 if (status && status >= 500) return { error: `${context} upstream is unavailable` };
8 if (error.code === 'ECONNABORTED') return { error: `${context} timed out` };
9 if (error.code === 'ENOTFOUND') return { skipped: 'Host could not be resolved' };
10 if (error.code === 'ECONNREFUSED') return { error: 'Connection refused by upstream' };
11 return { error: `${context} failed: ${error.message}` };
12};
13
14// Read a required env var, or return a skipped envelope if missing
15export const requireEnv = (envVar, service) => {

Callers 15

redirectsHandlerFunction · 0.90
linkedPagesHandlerFunction · 0.90
headersHandlerFunction · 0.90
sitemapHandlerFunction · 0.90
tlsLabsHandlerFunction · 0.90
dnsHandlerFunction · 0.90
rankHandlerFunction · 0.90
robotsHandlerFunction · 0.90
socialTagsHandlerFunction · 0.90
safeBrowsingFunction · 0.90
urlHausFunction · 0.90
phishTankFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected