node.js contact form handler using Mailgun and ReCaptcha
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.npmignore
.travis.yml
LICENSE
Makefile
README.md
index.js
package.json

README.md

ravens

node.js contact form handler using ReCaptcha

installation

$ npm install ravens

usage

var Ravens = require('ravens');

var ravens = Ravens({
	recaptcha_public_key:'...',
	recaptcha_private_key:'...'
})

ravens.on('send', function(formdata){

	// this formdata has been validated by ReCaptcha
	// you can use it to send an email or do whatever

})

var app = express();

// mount the form submit route onto the express application
app.use('/contactsubmit', ravens.handler());

Ravens(appconfig)

create a new express handler with the following properties:

  • recaptcha_public_key - the public key for your recaptcha account
  • recaptcha_private_key - the private key for your recaptcha account

events

these events are emitted by a ravens instance:

emit('send', formdata)

gives a chance to mess with the formdata before the emails are sent

form data

When you submit formdata to the handler - the request body must be JSON and must contain the following fields:

  • recaptcha_challenge_field
  • recaptcha_response_field

These are acquired by using the ReCaptcha client libraries.

There is an angular plugin for Ravens that renders a nice contact form with Recaptcha Plugin built in - ng-ravens.

license

MIT