https://github.com/pthm/imnar
A module for verifying ReCaptcha responses (with Express middleware)
https://github.com/pthm/imnar
Last synced: 8 months ago
JSON representation
A module for verifying ReCaptcha responses (with Express middleware)
- Host: GitHub
- URL: https://github.com/pthm/imnar
- Owner: pthm
- License: mit
- Created: 2015-06-18T20:58:30.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-22T23:45:52.000Z (almost 11 years ago)
- Last Synced: 2025-09-30T21:17:21.700Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.09 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IMNAR [](https://travis-ci.org/pthm/imnar)

🙋**A module for verifying ReCaptcha responses**
[](https://www.npmjs.com/package/imnar)
## Options
* **secret** (String) - Google ReCaptcha server secret
* **sendIp** (Boolean) - Only available for middleware, will send the `request.ip` value to be verified
* **endRequest** (Boolean) - Only available for middleware, if the checks fail it will send a 400 response and not continue the middleware chain
## Usage
### Express / Connect
When using IMAR with Express it needs a bodyParser higher up the middleware chain as it reads the ReCaptcha response
from `request.body['g-recpatcha-response']`
````javascript
var ReCaptcha = require('imnar');
var bodyParser = require('body-parser');
ReCaptcha({
secret: 'RECAPTCHA_SECRET_HERE',
sendIp: false
})
app.use(bodyParser.urlencoded({ extended: false }));
app.use(ReCaptcha.middleware);
````
### Standalone
You can use IMAR without Express by calling `.check(response, [ip])` the IP value is optional, this will return a promise.
````javascript
var ReCaptcha = require('imnar');
ReCaptcha({
secret: 'RECAPTCHA_SECRET_HERE',
sendIp: false
})
ReCaptcha.check('g-recaptcha-response').then(function(success){
console.log('Woohoo! captcha passed');
}, function(error){
console.log('Uh oh! looks like you\'re a robot');
})
````