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.2 to 1.0.3

8

index.js

@@ -57,6 +57,10 @@ 'use strict'

const lastFile = body[field][body[field].length - 1]
file.on('data', data => { fileData.push(data) })
file.on('data', data => { if (!lastFile.limit) { fileData.push(data) } })
file.on('limit', () => { lastFile.limit = true })
file.on('end', () => {
lastFile.data = Buffer.concat(fileData)
if (!lastFile.limit) {
lastFile.data = Buffer.concat(fileData)
} else {
lastFile.data = undefined
}
})

@@ -63,0 +67,0 @@ }

{
"name": "fastify-multipart",
"version": "1.0.2",
"version": "1.0.3",
"description": "Multipart plugin for Fastify",

@@ -15,19 +15,19 @@ "main": "index.js",

"@types/busboy": "^0.2.3",
"@types/node": "^12.0.6",
"@typescript-eslint/parser": "^1.7.0",
"@types/node": "^12.11.7",
"@typescript-eslint/parser": "^2.0.0",
"climem": "^1.0.3",
"concat-stream": "^2.0.0",
"eslint": "^5.16.0",
"eslint-config-standard": "^13.0.1",
"eslint-config-standard-with-typescript": "^7.0.0",
"eslint": "^6.6.0",
"eslint-config-standard": "^14.0.0",
"eslint-config-standard-with-typescript": "^8.0.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-typescript": "^0.14.0",
"fastify": "^2.0.0",
"form-data": "^2.3.2",
"form-data": "^3.0.0",
"pre-commit": "^1.2.2",
"pump": "^3.0.0",
"snazzy": "^8.0.0",
"standard": "^13.0.1",
"standard": "^14.0.2",
"tap": "^12.7.0",

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

@@ -90,2 +90,4 @@ # fastify-multipart

Note, if the file size limit is exceeded the file will not be attached to the body.
Additionally, you can pass per-request options to the req.multipart function

@@ -92,0 +94,0 @@

@@ -66,2 +66,45 @@ 'use strict'

test('addToBody with limit exceeded', t => {
t.plan(5)
const fastify = Fastify()
t.tearDown(fastify.close.bind(fastify))
fastify.register(multipart, { addToBody: true, limits: { fileSize: 1 } })
fastify.post('/', function (req, reply) {
t.equals(req.body.myFile[0].limit, true)
t.equals(req.body.myFile[0].data, undefined)
reply.send('ok')
})
fastify.listen(0, function () {
// request
var form = new FormData()
var opts = {
protocol: 'http:',
hostname: 'localhost',
port: fastify.server.address().port,
path: '/',
headers: form.getHeaders(),
method: 'POST'
}
var req = http.request(opts, (res) => {
t.equal(res.statusCode, 200)
res.resume()
res.on('end', () => {
t.pass('res ended successfully')
})
})
var rs = fs.createReadStream(filePath)
form.append('myFile', rs)
pump(form, req, function (err) {
t.error(err, 'client pump: no err')
})
})
})
test('addToBody option and multiple files', t => {

@@ -68,0 +111,0 @@ t.plan(7)

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