Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/boywithkeyboard-archive/turnstile

A type-safe server-side validator for Turnstile, Cloudflare's free CAPTCHA solution.
https://github.com/boywithkeyboard-archive/turnstile

cjs cloudflare deno esm javascript node turnstile typescript

Last synced: 12 days ago
JSON representation

A type-safe server-side validator for Turnstile, Cloudflare's free CAPTCHA solution.

Awesome Lists containing this project

README

        

## turnstile

> [!IMPORTANT]
> Please [read this article](https://developers.cloudflare.com/turnstile/get-started/server-side-validation) to learn more.

### Setup

#### Deno

```ts
import { turnstile } from 'https://esm.sh/@boywithkeyboard/turnstile'
```

#### Node.js

```bash
npm i @boywithkeyboard/turnstile
```

```ts
import { turnstile } from '@boywithkeyboard/turnstile'
```

### Usage

```ts
async function handleRequest(req) {
const body = await req.formData()

const result = await turnstile.verify({
secret: '...',
response: body.get('cf-turnstile-response'),
ip: req.headers.get('cf-connecting-ip')
})
}
```