Socket
Socket
Sign inDemoInstall

@fastify/formbody

Package Overview
Dependencies
1
Maintainers
19
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.1 to 7.1.0

.taprc

25

package.json
{
"name": "@fastify/formbody",
"version": "7.0.1",
"version": "7.1.0",
"description": "A module for Fastify to parse x-www-form-urlencoded bodies",

@@ -9,6 +9,5 @@ "main": "formbody.js",

"lint": "standard | snazzy",
"lint:ci": "standard",
"test": "standard && tap --100 \"test/**/*.test.js\" && tsd",
"test:ci": "tap --100 \"test/**/*.test.js\"",
"typescript": "tsd"
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "tap",
"test:typescript": "tsd"
},

@@ -34,18 +33,16 @@ "precommit": [

"devDependencies": {
"@types/node": "^17.0.0",
"codecov": "^3.7.2",
"fastify": "^4.0.0-rc.3",
"pre-commit": "^1.2.2",
"@fastify/pre-commit": "^2.0.2",
"@types/node": "^18.0.0",
"fastify": "^4.0.0-rc.2",
"form-auto-content": "^2.2.0",
"qs": "^6.5.1",
"request": "^2.88.0",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.20.0",
"typescript": "^4.0.2"
"tsd": "^0.22.0"
},
"dependencies": {
"fastify-plugin": "^3.0.0"
"fastify-plugin": "^4.0.0"
},
"types": "formbody.d.ts",
"types": "types/formbody.d.ts",
"publishConfig": {

@@ -52,0 +49,0 @@ "access": "public"

@@ -13,4 +13,6 @@ # @fastify/formbody

This branch targets Fastify v3. Please refer to [this branch](https://github.com/fastify/fastify-formbody/tree/3.x) and related versions for Fastify `^2.0.0` compatibility.
This branch targets Fastify v4. Please refer to [this branch](https://github.com/fastify/fastify-formbody/tree/3.x) and related versions for Fastify `^2.0.0` compatibility.
For Fastify v3 support, please use @fastify/formbody `^6.0.1`.
## Example

@@ -29,3 +31,3 @@

fastify.listen(8000, (err) => {
fastify.listen({ port: 8000 }, (err) => {
if (err) throw err

@@ -32,0 +34,0 @@ })

@@ -6,5 +6,5 @@ 'use strict'

const Fastify = require('fastify')
const request = require('request')
const plugin = require('../')
const qs = require('qs')
const formAutoContent = require('form-auto-content')

@@ -24,11 +24,6 @@ test('succes route succeeds', (t) => {

const reqOpts = {
method: 'POST',
baseUrl: 'http://localhost:' + fastify.server.address().port
}
const req = request.defaults(reqOpts)
req({ uri: '/test1', form: { foo: 'foo' } }, (err, response, body) => {
fastify.inject({ path: '/test1', method: 'POST', ...formAutoContent({ foo: 'foo' }) }, (err, response) => {
t.error(err)
t.equal(response.statusCode, 200)
t.same(JSON.parse(body), { foo: 'foo', message: 'done' })
t.same(JSON.parse(response.body), { foo: 'foo', message: 'done' })
})

@@ -51,12 +46,7 @@ })

const reqOpts = {
method: 'POST',
baseUrl: 'http://localhost:' + fastify.server.address().port
}
const req = request.defaults(reqOpts)
const payload = require('crypto').randomBytes(128).toString('hex')
req({ uri: '/limited', form: { foo: payload } }, (err, response, body) => {
fastify.inject({ path: '/limited', method: 'POST', ...formAutoContent({ foo: payload }) }, (err, response) => {
t.error(err)
t.equal(response.statusCode, 413)
t.equal(JSON.parse(body).message, 'Request body is too large')
t.equal(JSON.parse(response.body).message, 'Request body is too large')
})

@@ -86,10 +76,2 @@ })

const reqOpts = {
method: 'POST',
baseUrl: 'http://localhost:' + fastify.server.address().port,
headers: {
'content-type': 'application/x-www-form-urlencoded'
}
}
const req = request.defaults(reqOpts)
let sent = false

@@ -102,6 +84,6 @@ const payload = require('stream').Readable({

})
req({ uri: '/limited', body: payload }, (err, response, body) => {
fastify.inject({ path: '/limited', method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, body: payload }, (err, response) => {
t.error(err)
t.equal(response.statusCode, 413)
t.equal(JSON.parse(body).message, 'Request body is too large')
t.equal(JSON.parse(response.body).message, 'Request body is too large')
})

@@ -124,12 +106,7 @@ })

const reqOpts = {
method: 'POST',
baseUrl: 'http://localhost:' + fastify.server.address().port
}
const req = request.defaults(reqOpts)
const payload = require('crypto').randomBytes(128).toString('hex')
req({ uri: '/limited', form: { foo: payload } }, (err, response, body) => {
fastify.inject({ path: '/limited', method: 'POST', ...formAutoContent({ foo: payload }) }, (err, response) => {
t.error(err)
t.equal(response.statusCode, 413)
t.equal(JSON.parse(body).message, 'Request body is too large')
t.equal(JSON.parse(response.body).message, 'Request body is too large')
})

@@ -152,12 +129,7 @@ })

const reqOpts = {
method: 'POST',
baseUrl: 'http://localhost:' + fastify.server.address().port
}
const req = request.defaults(reqOpts)
const payload = require('crypto').randomBytes(128).toString('hex')
req({ uri: '/limited', form: { foo: payload } }, (err, response, body) => {
fastify.inject({ path: '/limited', method: 'POST', ...formAutoContent({ foo: payload }) }, (err, response) => {
t.error(err)
t.equal(response.statusCode, 413)
t.equal(JSON.parse(body).message, 'Request body is too large')
t.equal(JSON.parse(response.body).message, 'Request body is too large')
})

@@ -191,11 +163,6 @@ })

const reqOpts = {
method: 'POST',
baseUrl: 'http://localhost:' + fastify.server.address().port
}
const req = request.defaults(reqOpts)
req({ uri: '/test1', form: { 'foo[one]': 'foo', 'foo[two]': 'bar' } }, (err, response, body) => {
fastify.inject({ path: '/test1', method: 'POST', ...formAutoContent({ 'foo[one]': 'foo', 'foo[two]': 'bar' }) }, (err, response) => {
t.error(err)
t.equal(response.statusCode, 200)
t.same(JSON.parse(body), { 'foo[one]': 'foo', 'foo[two]': 'bar', message: 'done' })
t.same(JSON.parse(response.body), { 'foo[one]': 'foo', 'foo[two]': 'bar', message: 'done' })
})

@@ -219,13 +186,8 @@ })

const reqOpts = {
method: 'POST',
baseUrl: 'http://localhost:' + fastify.server.address().port
}
const req = request.defaults(reqOpts)
req({ uri: '/test1', form: { 'foo[one]': 'foo', 'foo[two]': 'bar' } }, (err, response, body) => {
fastify.inject({ path: '/test1', method: 'POST', ...formAutoContent({ 'foo[one]': 'foo', 'foo[two]': 'bar' }) }, (err, response) => {
t.error(err)
t.equal(response.statusCode, 200)
t.same(JSON.parse(body), { foo: { one: 'foo', two: 'bar' }, message: 'done' })
t.same(JSON.parse(response.body), { foo: { one: 'foo', two: 'bar' }, message: 'done' })
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc