MCPcopy
hub / github.com/soketi/soketi / broadcastEventRateLimitingMiddleware

Method broadcastEventRateLimitingMiddleware

src/http-handler.ts:502–516  ·  view source on GitHub ↗
(res: HttpResponse, next: CallableFunction)

Source from the content-addressed store, hash-verified

500 }
501
502 protected broadcastEventRateLimitingMiddleware(res: HttpResponse, next: CallableFunction): any {
503 let channels = res.body.channels || [res.body.channel];
504
505 this.server.rateLimiter.consumeBackendEventPoints(Math.max(channels.length, 1), res.app).then(response => {
506 if (response.canContinue) {
507 for (let header in response.headers) {
508 res.writeHeader(header, '' + response.headers[header]);
509 }
510
511 return next(null, res);
512 }
513
514 this.tooManyRequestsResponse(res);
515 });
516 }
517
518 protected broadcastBatchEventsRateLimitingMiddleware(res: HttpResponse, next: CallableFunction): any {
519 let rateLimiterPoints = res.body.batch.reduce((rateLimiterPoints, event) => {

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected