MCPcopy Create free account
hub / github.com/Noumena-Network/code / checkEndpoint

Function checkEndpoint

src/utils/preflightChecks.tsx:51–85  ·  view source on GitHub ↗
(
      endpoint: PreflightEndpointCheck,
    )

Source from the content-addressed store, hash-verified

49 try {
50 const endpoints = getPreflightEndpointChecks();
51 const checkEndpoint = async (
52 endpoint: PreflightEndpointCheck,
53 ): Promise<PreflightCheckResult> => {
54 try {
55 const response = await axios.request({
56 url: endpoint.url,
57 method: endpoint.method,
58 data: endpoint.data,
59 timeout: 5000,
60 validateStatus: () => true,
61 headers: {
62 'User-Agent': getUserAgent(),
63 ...endpoint.headers,
64 }
65 });
66 if (!endpoint.expectedStatuses.includes(response.status)) {
67 const hostname = new URL(endpoint.url).hostname;
68 return {
69 success: false,
70 error: `Failed to connect to ${hostname}: Status ${response.status}`
71 };
72 }
73 return {
74 success: true
75 };
76 } catch (error) {
77 const hostname = new URL(endpoint.url).hostname;
78 const sslHint = getSSLErrorHint(error);
79 return {
80 success: false,
81 error: `Failed to connect to ${hostname}: ${error instanceof Error ? (error as ErrnoException).code || error.message : String(error)}`,
82 sslHint: sslHint ?? undefined
83 };
84 }
85 };
86 const results = await Promise.all(endpoints.map(checkEndpoint));
87 const failedResult = results.find(result => !result.success);
88 if (failedResult) {

Callers

nothing calls this directly

Calls 3

getUserAgentFunction · 0.85
getSSLErrorHintFunction · 0.85
requestMethod · 0.45

Tested by

no test coverage detected