Skip to content

halitsever/nest-cloudflare-turnstile

Repository files navigation


☁️ Cloudflare Turnstile integration for NestJS


Documentation

  • 🧩 Simple and easy - This library provides just one guard to protect your endpoints with Cloudflare Turnstile Captcha!

Installation:

npm install nest-cloudflare-turnstile --save

add module to imports array:

  imports: [TurnstileModule.forRoot({
    secretKey: '1x0000000000000000000000000000000AA',
    tokenResponse: (req) => req.body.turnstileToken // or you can use req.headers.turnstileToken
  })],

use TurnstileCaptcha decorator on controller:

  import { TurnstileCaptcha } from 'nest-cloudflare-turnstile'

  @Post()
  @TurnstileCaptcha()
  getHello(): string {
    return this.appService.getHello();
  }

And thats it! For more information, please check the docs

MIT LICENSE | Halit Sever