UNPKG

homebridge-config-ui-x

Version:

A web based management, configuration and control platform for Homebridge

25 lines (19 loc) 519 B
'use strict' const fp = require('fastify-plugin') const qs = require('qs') function formBodyPlugin (fastify, options, next) { const opts = Object.assign({}, options || {}) function contentParser (req, body, done) { done(null, qs.parse(body.toString())) } fastify.addContentTypeParser( 'application/x-www-form-urlencoded', { parseAs: 'buffer', bodyLimit: opts.bodyLimit }, contentParser ) next() } module.exports = fp(formBodyPlugin, { fastify: '^2.0.0', name: 'fastify-formbody' })