recaptcha-middleware

2.0.0 • Public • Published

recaptcha-middleware

Build Status Coverage Status

Installation

npm install recaptcha-middleware --save

Usage

 
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

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)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    7
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    7
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i recaptcha-middleware

Weekly Downloads

7

Version

2.0.0

License

ISC

Last publish

Collaborators

  • confuser