Guards
Guard listesi
| Guard | Açıklama |
|---|---|
CaptchaGuard | Aktif sağlayıcı ile captcha token’ını doğrulayarak HTTP route’larını korur. |
Nasıl çalışır?
- Captcha token’ını headers (varsayılan) veya body içinden okur
CaptchaService.verifyAsync(token)ile doğrular- Token yoksa/geçersizse
UnauthorizedExceptionfırlatır
Kullanım
example.controller.ts
import { Controller, Post, UseGuards } from '@nestjs/common';
import { CaptchaGuard } from 'nestjs-captcha-module';
@Controller('example')
export class ExampleController {
@Post('submit')
@UseGuards(CaptchaGuard)
submit() {
return { ok: true };
}
}
not
Varsayılan olarak guard, token’ı x-captcha-token header’ında bekler.
Bunu modülü register ederken guardOptions ile özelleştirebilirsiniz.