A Fastify plugin for CloudFlare Turnstile Captcha
npm install fastify-cloudflare-turnstileA Cloudflare Turnstile plugin for fastify.
This plugin does the Server-side Validation for Cloudflare Turnstile and it is upto you to implement Client-side Validation
```
npm i fastify-cloudflare-turnstile
`javascript
const fastify = require('fastify');
const cfTurnstile = require('fastify-cloudflare-turnstile')
const app = fastify();
app.register(cfTurnstile,{
sitekey:"your_sitekey",
privatekey:"your_privatekey",
})
`
Using in a route
`javascript``
fastify.post('/login', {
preValidation: fastify.cfTurnstile,
schema: {
summary: 'User login',
body: {
type: 'object',
properties: {
email: {
anyOf: [
{ type: 'string' },
{ type: 'object' }
]
},
password: {
anyOf: [
{ type: 'string' },
{ type: 'object' }
]
}
},
required: ['email', 'password']
}
}
},
async function (req, reply) {
// Login logic
})