mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-11 22:02:21 +00:00
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:
1 parent
82e2b716bc
commit
94ff78be3b
1 file changed
+3
-5
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user