File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -16,13 +16,16 @@ export default class UploadPlugin extends AdminForthPlugin {
1616
1717 resourceConfig : AdminForthResource ;
1818
19+ rateLimiter : RateLimiter ;
20+
1921 constructor ( options : PluginOptions ) {
2022 super ( options , import . meta. url ) ;
2123 this . options = options ;
2224
2325 // for calcualting average time
2426 this . totalCalls = 0 ;
2527 this . totalDuration = 0 ;
28+ this . rateLimiter = new RateLimiter ( this . options . generation . rateLimit ?. limit )
2629 }
2730
2831 instanceUniqueRepresentation ( pluginOptions : any ) : string {
@@ -351,8 +354,7 @@ export default class UploadPlugin extends AdminForthPlugin {
351354 // this.options.generation.rateLimit?.limit,
352355 // this.adminforth.auth.getClientIp(headers),
353356 // );
354- const rateLimiter = new RateLimiter ( this . options . generation . rateLimit ?. limit ) ;
355- if ( ! rateLimiter . consume ( `${ this . pluginInstanceId } -${ this . adminforth . auth . getClientIp ( headers ) } ` ) ) {
357+ if ( ! await this . rateLimiter . consume ( `${ this . pluginInstanceId } -${ this . adminforth . auth . getClientIp ( headers ) } ` ) ) {
356358 return { error : this . options . generation . rateLimit . errorMessage } ;
357359 }
358360 }
You can’t perform that action at this time.
0 commit comments