Better Forms
A better way to create, validate and handle forms in Express
Use Better Forms to create your form, securely handle requests, validate form data and display validation errors.
Example usage
Build a form, giving it a name and fields. More examples
var forms = ; moduleexports = ;
Hook up your router to use form.requestHandler for each form request and Better Forms will process the request accordingly
var form = ; app ;
Print out the form mark up in your template
doctype htmlhtml(lang="en") head meta(charset='utf-8') title Simple Form body !=forms.simpleform.html
Add CSRF support. Install csurf
$ npm install csurf
And use it in your server
app
Set a token in your middleware
module { return { reslocals_csrf = req; ; };};
Use the middleware in your server
app
Setup
Install
npm install better-forms
Test
npm test
Lint
npm run lint
Examples
$ git clone git@github.com:JoeChapman/better-forms.git
$ cd better-forms
$ npm install
then run an example such as,
$ node examples/simple/server
and browse to http://localhost:3030