summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/ApiCallService.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-11-28 11:17:27 +0000
committerdakkar <dakkar@thenautilus.net>2024-11-28 11:17:27 +0000
commiteb25238a8eca0ef2adab4aab80de44375c086ed5 (patch)
treeea246e1c8d4d2dbc79054c7d4750213beb1cfae7 /packages/backend/src/server/api/ApiCallService.ts
parenthonour blocks and "signing required" for note versions (diff)
parentmerge: Bump develop version (!789) (diff)
downloadsharkey-eb25238a8eca0ef2adab4aab80de44375c086ed5.tar.gz
sharkey-eb25238a8eca0ef2adab4aab80de44375c086ed5.tar.bz2
sharkey-eb25238a8eca0ef2adab4aab80de44375c086ed5.zip
Merge branch 'develop' into feature/2024.10
Diffstat (limited to 'packages/backend/src/server/api/ApiCallService.ts')
-rw-r--r--packages/backend/src/server/api/ApiCallService.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts
index 016db6ac19..6f51825494 100644
--- a/packages/backend/src/server/api/ApiCallService.ts
+++ b/packages/backend/src/server/api/ApiCallService.ts
@@ -311,7 +311,15 @@ export class ApiCallService implements OnApplicationShutdown {
throw new ApiError(accessDenied);
}
- if (ep.meta.limit) {
+ // For endpoints without a limit, the default is 10 calls per second
+ const endpointLimit: IEndpointMeta['limit'] = ep.meta.limit ?? {
+ duration: 1000,
+ max: 10,
+ };
+
+ // We don't need this check, but removing it would cause a big merge conflict.
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+ if (endpointLimit) {
// koa will automatically load the `X-Forwarded-For` header if `proxy: true` is configured in the app.
let limitActor: string;
if (user) {
@@ -320,7 +328,7 @@ export class ApiCallService implements OnApplicationShutdown {
limitActor = getIpHash(request.ip);
}
- const limit = Object.assign({}, ep.meta.limit);
+ const limit = Object.assign({}, endpointLimit);
if (limit.key == null) {
(limit as any).key = ep.name;