Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/formbody

Package Overview
Dependencies
Maintainers
19
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/formbody - npm Package Compare versions

Comparing version 7.3.0 to 7.4.0

12

formbody.js
'use strict'
const fp = require('fastify-plugin')
const { parse } = require('fast-querystring')
const { parse: defaultParser } = require('fast-querystring')
function defaultParser (str) {
return parse(str)
}
function formBodyPlugin (fastify, options, next) {
function fastifyFormbody (fastify, options, next) {
const opts = Object.assign({ parser: defaultParser }, options)

@@ -29,5 +25,7 @@ if (typeof opts.parser !== 'function') {

module.exports = fp(formBodyPlugin, {
module.exports = fp(fastifyFormbody, {
fastify: '4.x',
name: '@fastify/formbody'
})
module.exports.default = fastifyFormbody
module.exports.fastifyFormbody = fastifyFormbody
{
"name": "@fastify/formbody",
"version": "7.3.0",
"version": "7.4.0",
"description": "A module for Fastify to parse x-www-form-urlencoded bodies",

@@ -35,3 +35,3 @@ "main": "formbody.js",

"fastify": "^4.0.0-rc.2",
"form-auto-content": "^2.2.0",
"form-auto-content": "^3.0.0",
"qs": "^6.5.1",

@@ -41,3 +41,3 @@ "snazzy": "^9.0.0",

"tap": "^16.0.0",
"tsd": "^0.23.0"
"tsd": "^0.24.1"
},

@@ -44,0 +44,0 @@ "dependencies": {

import { FastifyPluginCallback } from 'fastify'
export interface FormBodyPluginOptions {
bodyLimit?: number
parser?: (str: string) => Record<string, unknown>
type FastifyFormbody = FastifyPluginCallback<fastifyFormbody.FastifyFormbodyOptions>
declare namespace fastifyFormbody {
export interface FastifyFormbodyOptions {
bodyLimit?: number
parser?: (str: string) => Record<string, unknown>
}
/**
* @deprecated Use FastifyFormbodyOptions instead
*/
export type FormBodyPluginOptions = FastifyFormbodyOptions
export const fastifyFormbody: FastifyFormbody
export { fastifyFormbody as default }
}
declare const formBodyPlugin: FastifyPluginCallback<FormBodyPluginOptions>;
export default formBodyPlugin
declare function fastifyFormbody(...params: Parameters<FastifyFormbody>): ReturnType<FastifyFormbody>
export = fastifyFormbody
import fastify from 'fastify'
import querystring from 'querystring'
import formBodyPlugin, { FormBodyPluginOptions } from '..'
import { expectDeprecated, expectError, expectType } from 'tsd'
import formBodyPlugin, { FastifyFormbodyOptions, FormBodyPluginOptions } from '..'

@@ -8,13 +9,13 @@ const app = fastify()

const emptyOpts: FormBodyPluginOptions = {}
app.register(formBodyPlugin, emptyOpts)
const bodyLimitOpts: FormBodyPluginOptions = {
app.register(formBodyPlugin, { })
app.register(formBodyPlugin, {
bodyLimit: 1000
}
app.register(formBodyPlugin, bodyLimitOpts)
})
app.register(formBodyPlugin, {
parser: (s) => querystring.parse(s)
})
const parserOpts: FormBodyPluginOptions = {
parser: (s) => querystring.parse(s)
}
app.register(formBodyPlugin, parserOpts)
expectType<FormBodyPluginOptions>({} as FastifyFormbodyOptions)
expectDeprecated({} as FormBodyPluginOptions)
expectError(app.register(formBodyPlugin, { invalid: true }))
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