New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-form-post

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-form-post - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

59

index.js

@@ -10,20 +10,18 @@ "use strict";

// validateFile
if(user_options.validateFile) {
if(typeof user_options.validateFile != "function") throw new Error("option 'validateFile' must be a function.");
} else {
user_options.validateFile = (file, handlePromise) => handlePromise();
}
/*
* validateBody validates the req.body before sending off files to the store
* if validateBody is set in any way, the file buffers will be sent to the store after the request has been validated
* This means that file_contents.end() only triggers after the "end" event is emitted
*/
if(user_options.validateBody) {
if(typeof user_options.validateBody != "function") throw new Error("option validateBody must be a function.");
} else {
user_options.validateBody = (body, handlePromise) => handlePromise();
}
["validateFile", "validateBody"].forEach((validateFunctionKey) => {
/*
* validateBody validates the req.body before sending off files to the store
* The file buffers will be sent to the store after the request has been validated
* This means that file_contents.end() only triggers after the "end" event is emitted
*/
if(user_options[validateFunctionKey]) {
if(typeof user_options[validateFunctionKey] !== "function") {
let err_msg = "option '" + validateFunctionKey + "' must be a function.";
throw new Error(err_msg);
}
} else {
user_options[validateFunctionKey] = (information, handlePromise) => handlePromise();
}
});
// Available storage methods

@@ -64,4 +62,19 @@ if(!["disk", "aws-s3", "dropbox"].includes(user_options.store)) {

["minfileSize", "maxfileSize"].forEach((limitfileSizeKey) => {
switch(typeof user_options[limitfileSizeKey]) {
case "object":
break;
case "undefined":
case "number":
user_options[limitfileSizeKey] = {
size: user_options[limitfileSizeKey] || (limitfileSizeKey === "minfileSize" ? 0 : undefined)
};
break;
default: {
throw new Error("option '" + limitfileSizeKey + "' must be either an object or a number");
break;
}
}
});
this.opts = {

@@ -71,4 +84,4 @@ store: user_options.store,

filename: user_options.filename,
maxfileSize: typeof user_options.maxfileSize === "object" ? user_options.maxfileSize : { size: user_options.maxfileSize },
minfileSize: typeof user_options.minfileSize === "object" ? user_options.minfileSize : { size: user_options.minfileSize || 0},
maxfileSize: user_options.maxfileSize,
minfileSize: user_options.minfileSize,
validateFile: user_options.validateFile,

@@ -82,3 +95,3 @@ validateBody: user_options.validateBody,

let checkApi = () => {
if(!this.opts.api) throw new Error("You must specify api information to use " + this.opts.storage + " storage");
if(!this.opts.api) throw new Error("You must specify api information to use " + this.opts.store + " storage");
};

@@ -151,2 +164,2 @@

module.exports = ExpressFormPost;
module.exports = ExpressFormPost;
{
"name": "express-form-post",
"version": "1.4.1",
"version": "1.4.2",
"description": "Simple, reliable and memory efficient http file parse and upload api",
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "mocha test/*",
"test:unit": "mocha test/unit"
},

@@ -9,0 +10,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc