cap

captcha

Simple captcha for Node.JS and Express.

Showing:

Popularity

Downloads/wk

7

GitHub Stars

131

Maintenance

Last Commit

5yrs ago

Contributors

5

Package

Dependencies

1

Size (min+gzip)

3.5KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Reviews

Average Rating

4.0/51
Read All Reviews
atomract

Top Feedback

1Great Documentation
1Easy to Use
1Unwelcoming Community

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)

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

Rate & Review

Great Documentation1
Easy to Use1
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community1
100
Siddhant AggarwalDehradun21 Ratings58 Reviews
Hi! I am Siddhant Aggarwal, I have been working on Robotics, Data Science, Machine Learning, MERN stack, React Native development, and IoT.
October 9, 2020
Easy to Use
Unwelcoming Community
Great Documentation

Captcha api is really useful mostly when you don't want another 3rd party library use it with node and express. Had very good experience


0

Tutorials

No tutorials found
Add a tutorial