refactor(routes): inline the single-use 502 responder

The outage branch is the only caller, so it writes its 502 directly.
Same status, headers and body.
This commit is contained in:
German Khokhlov committed 2026-11-11 21:23:35 +04:00
1 parent 82e2b716bc
commit 94ff78be3b
1 file changed
+3 -5
+3 -5
View File
@@ -267,10 +267,6 @@ export function installRouteMiddleware(
});
res.end(JSON.stringify({ ok: false, error: msg }));
};
const unavailable = (msg) => {
res.writeHead(502, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ ok: false, error: msg }));
};
try {
if (!_routeRateLimiter(clientKey(req))) {
rateLimited('rate limited', 5);
@@ -384,7 +380,9 @@ export function installRouteMiddleware(
);
}
if (upstreamError instanceof UpstreamUnavailableError) {
return unavailable(upstreamError.message);
res.writeHead(502, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ ok: false, error: upstreamError.message }));
return;
}
throw upstreamError;
}