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

Function vercelHandler

api/_common/middleware.js:62–84  ·  view source on GitHub ↗
(request, response)

Source from the content-addressed store, hash-verified

60
61 // Vercel
62 const vercelHandler = async (request, response) => {
63 if (DISABLE_EVERYTHING) {
64 return response.status(200).json({ skipped: disabledMsg });
65 }
66
67 const queryParams = request.query || {};
68 const rawUrl = queryParams.url;
69
70 if (!rawUrl) {
71 return response.status(500).json({ error: 'No URL specified' });
72 }
73
74 const url = normalizeUrl(rawUrl);
75
76 try {
77 const result = await Promise.race([handler(url, request), createTimeoutPromise(TIMEOUT)]);
78 response.status(200).json(typeof result === 'object' ? result : JSON.parse(result));
79 } catch (error) {
80 const isTimeout = error.message.includes('timed-out') || response.statusCode === 504;
81 const message = isTimeout ? `${error.message}\n\n${timeoutErrorMsg}` : error.message;
82 response.status(isTimeout ? 408 : 500).json({ error: message });
83 }
84 };
85
86 // Netlify
87 const netlifyHandler = async (event, context) => {

Callers

nothing calls this directly

Calls 2

normalizeUrlFunction · 0.85
createTimeoutPromiseFunction · 0.85

Tested by

no test coverage detected