# captcha

> Simple captcha middleware for Express

Latest version **0.1.3** (published 2017-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install captcha
pnpm add captcha
yarn add captcha
bun add captcha
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2017-04-21 |
| First published | 2012-01-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 135 |
| Author | napa3um |
| Maintainers | napa3um |

## Links

- npm: https://www.npmjs.com/package/captcha
- Repository: https://github.com/napa3um/node-captcha
- Homepage: https://github.com/napa3um/node-captcha#readme
- Issues: https://github.com/napa3um/node-captcha/issues
- npm.io page: https://npm.io/package/captcha

## Dependencies (1)

- [canvas](https://npm.io/package/canvas.md) ^1.6.5

## Recent versions

- 0.1.3 (latest) — 2017-04-21
- 0.1.2 — 2017-04-21
- 0.1.1 — 2017-04-21
- 0.1.0 — 2017-04-19
- 0.0.4 — 2012-11-24
- 0.0.3 — 2012-11-24
- 0.0.2 — 2012-11-24
- 0.0.1 — 2012-01-18

## README

# Captcha

Simple captcha for Express.

WARNING! New API (0.0.5 -> 0.1.0)

## Installation

Via npm:

	$ npm install captcha

## Usage (for Express 4)

```javascript
'use strict'

const express = require('express')
const session = require('express-session')
const bodyParser = require('body-parser')

const captchaUrl = '/captcha.jpg'
const captchaId = 'captcha'
const captchaFieldName = 'captcha'

const captcha = require('./captcha').create({ cookie: captchaId })

const app = express()
app.use(session({
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: true,
}))
app.use(bodyParser.urlencoded({ extended: false }))

app.get(captchaUrl, captcha.image())

app.get('/', (req, res) => {
    res.type('html')
    res.end(`
        <img src="${ captchaUrl }"/>
        <form action="/login" method="post">
            <input type="text" name="${ captchaFieldName }"/>
            <input type="submit"/>
        </form>
    `)
})

app.post('/login', (req, res) => {
    res.type('html')
    res.end(`
        <p>CAPTCHA VALID: ${ captcha.check(req, req.body[captchaFieldName]) }</p>
    `)
})

app.listen(8080, () => {
    console.log('server started')
})
```

---
_Source: https://npm.io/package/captcha · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
