|
|
|
@ -5,6 +5,8 @@ import { ThrottlerException, ThrottlerGuard } from '@nestjs/throttler'
@@ -5,6 +5,8 @@ import { ThrottlerException, ThrottlerGuard } from '@nestjs/throttler'
|
|
|
|
|
export class WsThrottlerGuard extends ThrottlerGuard { |
|
|
|
|
async handleRequest(context: ExecutionContext, limit: number, ttl: number): Promise<boolean> { |
|
|
|
|
const client = context.switchToWs().getClient() |
|
|
|
|
console.log('conn', client.conn) |
|
|
|
|
console.log('socket', client._socket) |
|
|
|
|
const ip = client._socket.remoteAddress |
|
|
|
|
const key = this.generateKey(context, ip) |
|
|
|
|
const { totalHits } = await this.storageService.increment(key, ttl) |
|
|
|
|