https://github.com/confuser/node-recaptcha-middleware
Simple recaptcha verifications
https://github.com/confuser/node-recaptcha-middleware
Last synced: 9 months ago
JSON representation
Simple recaptcha verifications
- Host: GitHub
- URL: https://github.com/confuser/node-recaptcha-middleware
- Owner: confuser
- License: isc
- Created: 2016-01-14T15:07:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-01T09:49:53.000Z (about 10 years ago)
- Last Synced: 2025-08-19T10:21:14.798Z (10 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# recaptcha-middleware
[](https://travis-ci.org/confuser/node-recaptcha-middleware)
[](https://coveralls.io/r/confuser/node-recaptcha-middleware?branch=master)
## Installation
```
npm install recaptcha-middleware --save
```
## Usage
```js
var app = require('express')()
, middleware = require('recaptcha-middleware')({ secretKey: 'secretKey' })
app.get('/hello', middleware, function (req, res, next) {
next()
})
app.post('/hello', middleware, function (req, res, next) {
next()
})
```
Requires either a body field `g-recaptcha-response` or query string parameter of the same name to support multiple HTTP verbs
## Override error messages
```js
var opts =
{ secretKey: 'secretKey'
, errors:
{ validation: function () { return new Error('Missing g-recaptcha-response field') }
, missingBody: function () { return new Error('Missing body response from recaptcha') }
, missingError: function () { return new Error('Recaptcha not successful but no error codes provided') }
, recaptchaErrorHandler: function (errors) {
return new Error(errors.join(', '))
}
}
}
, middleware = require('recaptcha-middleware')(opts)
```