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

1.0.8 • Public • Published

express-turnstile

Validate your CloudFlare Turnstile token using a Express middleware.

Usage

yarn add express-turnstile

Middleware is executed by calling turnstile.validate(siteSecret).

const express = require("express");
const { turnstile } = require("express-turnstile");

const app = express();

app.post(
  "/verify",
  turnstile.validate(process.env.TURNSTILE_SECRET),
  (req, res) => {
    res.json({ message: "verified!" });
  }
);

app.listen(3000, () => {
  console.log("Server started on port 3000");
});

Or as module

import express from "express";
import { turnstile } from "express-turnstile";

const app = express();

app.post(
  "/verify",
  turnstile.validate(process.env.TURNSTILE_SECRET),
  (req, res) => {
    res.json({ message: "verified!" });
  }
);

app.listen(3000, () => {
  console.log("Server started on port 3000");
});

Package Sidebar

Install

npm i express-turnstile

Weekly Downloads

0

Version

1.0.8

License

ISC

Unpacked Size

6.73 kB

Total Files

4

Last publish

Collaborators

  • opensource03