fastify-cloudflare-turnstile
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

fastify-cloudflare-turnstile

CI NPM version js-standard-style

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-turnstile

Usage

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
  })

Package Sidebar

Install

npm i fastify-cloudflare-turnstile

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

13.6 kB

Total Files

10

Last publish

Collaborators

  • ryleegeorge