Package Exports
- fastify-cloudflare-turnstile
- fastify-cloudflare-turnstile/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fastify-cloudflare-turnstile) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
fastify-cloudflare-turnstile
A 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
Install
npm i fastify-cloudflare-turnstileUsage
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
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
})