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

fastify-multipart

Package Overview
Dependencies
Maintainers
8
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-multipart - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

18

index.js

@@ -8,2 +8,3 @@ 'use strict'

const deepmerge = require('deepmerge')
const { PassThrough } = require('stream')

@@ -64,2 +65,14 @@ function setMultipart (req, done) {

function busboy (options) {
try {
return new Busboy(options)
} catch (error) {
const errorEmitter = new PassThrough()
process.nextTick(function () {
errorEmitter.emit('error', error)
})
return errorEmitter
}
}
function fastifyMultipart (fastify, options, done) {

@@ -115,3 +128,3 @@ if (options.addToBody === true) {

const busboyOptions = deepmerge.all([{ headers: req.headers }, options || {}, opts || {}])
const stream = new Busboy(busboyOptions)
const stream = busboy(busboyOptions)
var completed = false

@@ -143,2 +156,5 @@ var files = 0

req.pipe(stream)
.on('error', function (error) {
req.emit('error', error)
})

@@ -145,0 +161,0 @@ function wrap (field, file, filename, encoding, mimetype) {

10

package.json
{
"name": "fastify-multipart",
"version": "1.0.1",
"version": "1.0.2",
"description": "Multipart plugin for Fastify",

@@ -9,3 +9,3 @@ "main": "index.js",

"busboy": "^0.3.0",
"deepmerge": "^3.0.0",
"deepmerge": "^4.0.0",
"end-of-stream": "^1.4.1",

@@ -16,3 +16,3 @@ "fastify-plugin": "^1.5.0"

"@types/busboy": "^0.2.3",
"@types/node": "^11.13.9",
"@types/node": "^12.0.6",
"@typescript-eslint/parser": "^1.7.0",

@@ -22,3 +22,3 @@ "climem": "^1.0.3",

"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-config-standard": "^13.0.1",
"eslint-config-standard-with-typescript": "^7.0.0",

@@ -34,3 +34,3 @@ "eslint-plugin-import": "^2.17.2",

"snazzy": "^8.0.0",
"standard": "^12.0.1",
"standard": "^13.0.1",
"tap": "^12.7.0",

@@ -37,0 +37,0 @@ "typescript": "^3.4.5"

@@ -181,2 +181,47 @@ 'use strict'

test('should error if it is invalid multipart', function (t) {
t.plan(5)
const fastify = Fastify()
t.tearDown(fastify.close.bind(fastify))
fastify.register(multipart)
fastify.post('/', function (req, reply) {
t.ok(req.isMultipart())
req.multipart(handler, function (err) {
t.ok(err)
t.equal(err.message, 'Multipart: Boundary not found')
reply.code(500).send()
})
function handler (field, file, filename, encoding, mimetype) {
t.fail('this should never be called')
}
})
fastify.listen(0, function () {
// request
var form = new FormData()
var opts = {
protocol: 'http:',
hostname: 'localhost',
port: fastify.server.address().port,
headers: {
'content-type': 'multipart/form-data'
},
path: '/',
method: 'POST'
}
var req = http.request(opts, (res) => {
t.equal(res.statusCode, 500)
})
pump(form, req, function (err) {
t.error(err, 'client pump: no err')
})
})
})
test('should override options', function (t) {

@@ -183,0 +228,0 @@ t.plan(5)

Sorry, the diff of this file is not supported yet

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