app/integrations/server/api/api.js
/*
	There is only one generic route propagated to Restivus which has URL-path-parameters for the integration and the token.
	Since the rate-limiter operates on absolute routes, we need to add a limiter to the absolute url before we can validate it
	*/
There is only one generic route propagated to Restivus which has URL-path-parameters for the integration and the token.
Since the rate-limiter operates on absolute routes, we need to add a limiter to the absolute url before we can validate it
There is only one generic route propagated to Restivus which has URL - path - parameters for the integration and the token . Since the rate - limiter operates on absolute routes we need to add a limiter to the absolute url before we can validate it
enforceRateLimit(objectForRateLimitMatch, request, response, userId) {
		const { method, url } = request;
		const route = url.replace(`/${ this.apiPath }`, '');
		const nameRoute = this.getFullRouteName(route, [method.toLowerCase()]);
		if (!this.getRateLimiter(nameRoute)) {
			this.addRateLimiterRuleForRoutes({
				routes: [route],
				rateLimiterOptions: defaultRateLimiterOptions,
				endpoints: {
					post: executeIntegrationRest,
					get: executeIntegrationRest,
				},
			});
		}
		const integrationForRateLimitMatch = objectForRateLimitMatch;
		integrationForRateLimitMatch.route = nameRoute;
		super.enforceRateLimit(integrationForRateLimitMatch, request, response, userId);
	}
enforceRateLimit ( objectForRateLimitMatch , request , response , userId ) { const { method , url } = request ; const route = url . replace ( ` ${ this . apiPath } ` , '' ) ; const nameRoute = this . getFullRouteName ( route , [ method . toLowerCase ( ) ] ) ; if ( ! this . getRateLimiter ( nameRoute ) ) { this . addRateLimiterRuleForRoutes ( { routes : [ route ] , rateLimiterOptions : defaultRateLimiterOptions , endpoints : { post : executeIntegrationRest , get : executeIntegrationRest , } , } ) ; } const integrationForRateLimitMatch = objectForRateLimitMatch ; integrationForRateLimitMatch . route = nameRoute ; super . enforceRateLimit ( integrationForRateLimitMatch , request , response , userId ) ; }
There is only one generic route propagated to Restivus which has URL-path-parameters for the integration and the token.
There is only one generic route propagated to Restivus which has URL - path - parameters for the integration and the token .
// We'll be creating rate limiters on demand (when validating for the first time). // This is possible since *all* integration hooks should be rate limited the same way. // This way, we'll not have to add new limiters as new integrations are added