express-form-post
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -251,2 +251,6 @@ "use strict"; | ||
ExpressFormPost.prototype.fields = function() { | ||
return require("./lib/fields").bind(this); | ||
} | ||
ExpressFormPost.prototype.middleware = function(handleError = undefined) { | ||
@@ -259,5 +263,6 @@ this.middleware.handleError = handleError; // the function to be called inside handleError | ||
// Upload function to be used within routes. handleError set as callback as well and can be check with if (err) | ||
ExpressFormPost.prototype.upload = function(req, res, cb) { | ||
ExpressFormPost.prototype.upload = function(req, res, cb = () => {}) { | ||
typeof cb == "function" ? "" : cb = () => {}; // prevent user failure | ||
// reassign in fileHandler | ||
this.handleError = undefined; | ||
this.handleError = undefined; | ||
// cb is cb in fileHandler param | ||
@@ -264,0 +269,0 @@ fileHandler.bind(this)(req, res, cb); |
{ | ||
"name": "express-form-post", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "Simple, reliable express http file and post body handler.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -126,3 +126,3 @@ # Express Form Post [![npm version](https://badge.fury.io/js/express-form-post.svg)](https://badge.fury.io/js/express-form-post) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) | ||
#### express-form-post(opts) | ||
#### express-form-post([opts]) | ||
@@ -135,6 +135,6 @@ express-form-post accepts an "optional" options parameter list. Keep in mind all fields are OPTIONAL. If you don't provide any, the express-form-post api will take care of that using the default options. | ||
`directory` | The folder to which the file will be saved | defaults to current directory | ||
`filename` | function to determine file save name | defaults to the file's name on the user's computer | ||
`filename` | function to determine file save name | defaults to the a unique 64 bit hash generated by `hasha` | ||
`maxfileSize` | Maximum Size of the uploaded file in bytes | defaults to infiniti | ||
`minfileSize` | Minimum Size of the uploaded file in bytes | defaults to 0 | ||
`validate` | function to validate uploaded file | | ||
`validate` | function to validate uploaded file | takes two optional parameters: fieldname and mimetype | ||
`api` | api configuration information (api keys) | read further documentation for specifications | ||
@@ -147,2 +147,15 @@ | ||
### express-form-post handlers | ||
There are three different ways to handle form data with express-form-post. The three ways are available as methods in the instance of a express-form-post object. | ||
#### middleware([callback]) | ||
This method is used as middleware and provides a good layer of abstraction for file handling. | ||
#### upload(request, response[, callback]) | ||
This method is used inside routes as a function rather than middleware. This allows better readability and customizability. This function takes in three parameters : request, response, and an optional callback. The request and response object should be the ones provided by express. | ||
#### fields | ||
This method is used to only parse the fields and ignore the files. I would recommend against using this and to use `body-parser` instead, but fields is available for those who are not looking to download multiple modules that do the same. | ||
### Configuring API storage | ||
@@ -168,1 +181,6 @@ | ||
`selectUser` | Specific user in a team box | Optional | ||
#### Samples | ||
Samples are also available on the github page. Please take a look and reach out if you have any questions. [github](https://github.com/dannycho7/express-form-post) |
25117
13
427
182