simple-form-middleware

1.3.1 • Public • Published

simple-form-middleware

Description

A simple form middleware.

screenshot

Usage

$ npm install simple-form-middleware
import connect from 'connect'
import createForm from 'simple-form-middleware'

const app = connect()

app.use('/auth', createForm({
  action: '/login',
  method: 'post',
  fieldset: [
    {
      name: 'user_name',
      value: 'admin',
      'data-label': 'User name',
    },
    {
      name: 'user_pass',
      type: 'password',
      value: '123456',
      'data-label': 'Password',
    },
    {
      type: 'select',
      name: 'role',
      value: '1',
    },
    {
      name: 'code',
      type: 'captacha',
      'data-url': '/auth/test.png',
      required: true,
    },
  ],
  selectOptions: {
    role: [{
      value: '1',
      label: 'Admin',
    }, {
      value: '2',
      label: 'Guest',
    }],
  },
  headers: {
    'Content-Type': 'application/json',
  },
  callbackStr: `function(err, text) {
    alert(err ? err.message : text)
  }`,
  // externalScriptUrl: '/auth/printReqInfo.js',
))

app.listen(3000)

License

MIT

Dependencies (2)

Dev Dependencies (19)

Package Sidebar

Install

npm i simple-form-middleware

Weekly Downloads

1

Version

1.3.1

License

MIT

Last publish

Collaborators

  • zuojiang