https://github.com/halitsever/nest-cloudflare-turnstile
☁️ Cloudflare Turnstile Captcha integration for NestJS
https://github.com/halitsever/nest-cloudflare-turnstile
captcha cloudflare integration nest turnstile
Last synced: 24 days ago
JSON representation
☁️ Cloudflare Turnstile Captcha integration for NestJS
- Host: GitHub
- URL: https://github.com/halitsever/nest-cloudflare-turnstile
- Owner: halitsever
- License: mit
- Created: 2024-08-26T23:03:09.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-16T14:27:09.000Z (7 months ago)
- Last Synced: 2025-04-05T21:45:29.259Z (26 days ago)
- Topics: captcha, cloudflare, integration, nest, turnstile
- Language: TypeScript
- Homepage: https://halitsever.github.io/nest-cloudflare-turnstile
- Size: 750 KB
- Stars: 57
- Watchers: 1
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
☁️ Cloudflare Turnstile integration for NestJS
![]()
![]()
- 🧩 [**Simple and easy**](#) - This library provides just one guard to protect your endpoints with Cloudflare Turnstile Captcha!
![]()
Installation:
```bash
npm install nest-cloudflare-turnstile --save
```add module to imports array with forRoot method:
```javascript
imports: [TurnstileModule.forRoot({
secretKey: '1x0000000000000000000000000000000AA',
tokenResponse: (req) => req.body.turnstileToken // or you can use req.headers.turnstileToken
})],```
or with forRootAsync method:
```javascript
imports: [
TurnstileModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => {
const secretKey = config.get(
'CLOUDFLARE_TURNSTILE_PRIVATE_KEY',
);
if (!secretKey) {
throw new Error('Missing Cloudflare Turnstile secret');
}return {
secretKey,
tokenResponse: (req) => req.body.turnstileToken,
};
},
}),
]
```use `TurnstileCaptcha` decorator on controller:
```javascript
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