api/core: return 429 http status for rate-limit (#1066)

Co-authored-by: jj <log@riseup.net>
This commit is contained in:
lostdusty 2025-02-11 05:42:31 -03:00 committed by GitHub
parent ad23b70e9d
commit fa267ae54b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -61,13 +61,13 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
})
const handleRateExceeded = (_, res) => {
const { status, body } = createResponse("error", {
const { body } = createResponse("error", {
code: "error.api.rate_exceeded",
context: {
limit: env.rateLimitWindow
}
});
return res.status(status).json(body);
return res.status(429).json(body);
};
const keyGenerator = (req) => hashHmac(getIP(req), 'rate').toString('base64url');