Guards
Guards
์น ์์ผ guards์ regular guards์๋ ์ฐจ์ด๊ฐ ์์ต๋๋ค. ์์์ผ ํ ์ ์ผํ ๊ฒ์ HttpException
์ ๋ฐ์์ํค๋ ๋์ WsException
์ ์ฌ์ฉํด์ผ ํ๋ค๋ ๊ฒ์
๋๋ค.
info ํํธ
WsException
ํด๋์ค๋@nestjs/websockets
ํจํค์ง์์ ๋ ธ์ถ๋ฉ๋๋ค.
Binding guards
๋ค์์ method-scoped guard๋ฅผ ์ฌ์ฉํ๋ ์์ ์ ๋๋ค (class-scoped๋ ์๋ํฉ๋๋ค).
@@filename()
@UseGuards(AuthGuard)
@SubscribeMessage('events')
handleEvent(client: Client, data: unknown): WsResponse<unknown> {
const event = 'events';
return { event, data };
}
@@switch
@UseGuards(AuthGuard)
@SubscribeMessage('events')
handleEvent(client, data) {
const event = 'events';
return { event, data };
}
Last updated
Was this helpful?