fastify-xml-body-parser
Advanced tools
Comparing version
11
index.js
@@ -19,4 +19,12 @@ 'use strict' | ||
let body = '' | ||
req.on('error', errorListener) | ||
req.on('data', dataListener) | ||
req.on('end', endListener) | ||
function errorListener (err) { | ||
done(err) | ||
} | ||
function endListener () { | ||
done(null, qs.parse(body)) | ||
} | ||
function dataListener(data) { | ||
@@ -30,2 +38,5 @@ body = body + data | ||
invalidFormat.statusCode = 400 | ||
req.removeListener('error', errorListener) | ||
req.removeListener('data', dataListener) | ||
req.removeListener('end', endListener) | ||
done(invalidFormat) | ||
@@ -32,0 +43,0 @@ } |
{ | ||
"name": "fastify-xml-body-parser", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Fastify plugin to parse XML payload into JS object", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -56,3 +56,3 @@ # fastify-xml-body-parser | ||
## Options | ||
This plugin use [fastify-xml-body-parser](https://github.com/NaturalIntelligence/fastify-xml-body-parser) to parse the XML payload. So it accepts all the options supported by fastify-xml-body-parser. | ||
This plugin use [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) to parse the XML payload. So it accepts all the options supported by fast-xml-parser. | ||
@@ -88,2 +88,10 @@ ```js | ||
## License | ||
[MIT License](http://jsumners.mit-license.org/) | ||
[MIT License](http://jsumners.mit-license.org/) | ||
## Worth to mention | ||
Don't forget to check my other opensource projects | ||
* **[fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser)** : Validate XML or Parse XML to JS/JSON rapidly without C/C++ based libraries and no callback. Work with NPM, in all browsers, and CLI. | ||
* **[stubmatic](https://github.com/NaturalIntelligence/stubmatic)** : A QA friendly stub server to mock behaviour of HTTP(s) / REST / SOAP services. Now you can create simulators or mock services in few minutes without coding. | ||
* **[fast-lorem-ipsum](https://github.com/NaturalIntelligence/fast-lorem-ipsum)** : Generate lorem ipsum words, sentences, paragraph very quickly. Better than any generater. Works with NPM, browser, and CLI. |
94046
1.19%51
27.5%96
10.34%