mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	revert un-needed changes to RateLimiterService
This commit is contained in:
		
							parent
							
								
									f6b256620b
								
							
						
					
					
						commit
						fc5399a67d
					
				
					 1 changed files with 8 additions and 8 deletions
				
			
		| 
						 | 
					@ -10,29 +10,29 @@ import { DI } from '@/di-symbols.js';
 | 
				
			||||||
import type Logger from '@/logger.js';
 | 
					import type Logger from '@/logger.js';
 | 
				
			||||||
import { LoggerService } from '@/core/LoggerService.js';
 | 
					import { LoggerService } from '@/core/LoggerService.js';
 | 
				
			||||||
import { bindThis } from '@/decorators.js';
 | 
					import { bindThis } from '@/decorators.js';
 | 
				
			||||||
import type { LimitInfo } from '@/server/api/SkRateLimiterService.js';
 | 
					 | 
				
			||||||
import { EnvService } from '@/core/EnvService.js';
 | 
					 | 
				
			||||||
import type { IEndpointMeta } from './endpoints.js';
 | 
					import type { IEndpointMeta } from './endpoints.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** @deprecated Use SkRateLimiterService instead */
 | 
					/** @deprecated Use SkRateLimiterService instead */
 | 
				
			||||||
@Injectable()
 | 
					@Injectable()
 | 
				
			||||||
export class RateLimiterService {
 | 
					export class RateLimiterService {
 | 
				
			||||||
	protected readonly logger: Logger;
 | 
						private logger: Logger;
 | 
				
			||||||
	protected readonly disabled: boolean;
 | 
						private disabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	constructor(
 | 
						constructor(
 | 
				
			||||||
		@Inject(DI.redis)
 | 
							@Inject(DI.redis)
 | 
				
			||||||
		protected readonly redisClient: Redis.Redis,
 | 
							private redisClient: Redis.Redis,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		private loggerService: LoggerService,
 | 
							private loggerService: LoggerService,
 | 
				
			||||||
		envService: EnvService,
 | 
					 | 
				
			||||||
	) {
 | 
						) {
 | 
				
			||||||
		this.logger = this.loggerService.getLogger('limiter');
 | 
							this.logger = this.loggerService.getLogger('limiter');
 | 
				
			||||||
		this.disabled = envService.env.NODE_ENV !== 'production';
 | 
					
 | 
				
			||||||
 | 
							if (process.env.NODE_ENV !== 'production') {
 | 
				
			||||||
 | 
								this.disabled = true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@bindThis
 | 
						@bindThis
 | 
				
			||||||
	public limit(limitation: IEndpointMeta['limit'] & { key: NonNullable<string> }, actor: string, factor = 1): Promise<LimitInfo | void> {
 | 
						public limit(limitation: IEndpointMeta['limit'] & { key: NonNullable<string> }, actor: string, factor = 1) {
 | 
				
			||||||
		return new Promise<void>((ok, reject) => {
 | 
							return new Promise<void>((ok, reject) => {
 | 
				
			||||||
			if (this.disabled) ok();
 | 
								if (this.disabled) ok();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue