{"id":19500588,"url":"https://github.com/naturalintelligence/fastify-xml-body-parser","last_synced_at":"2025-04-25T23:30:29.844Z","repository":{"id":29334920,"uuid":"121242424","full_name":"NaturalIntelligence/fastify-xml-body-parser","owner":"NaturalIntelligence","description":"Fastify plugin / module to parse XML payload / body into JS object","archived":false,"fork":false,"pushed_at":"2024-07-30T08:19:49.000Z","size":217,"stargazers_count":19,"open_issues_count":3,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-20T16:39:34.332Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NaturalIntelligence.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-12T12:10:52.000Z","updated_at":"2023-11-27T08:36:16.000Z","dependencies_parsed_at":"2024-01-23T21:35:21.240Z","dependency_job_id":null,"html_url":"https://github.com/NaturalIntelligence/fastify-xml-body-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Ffastify-xml-body-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Ffastify-xml-body-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Ffastify-xml-body-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalIntelligence%2Ffastify-xml-body-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NaturalIntelligence","download_url":"https://codeload.github.com/NaturalIntelligence/fastify-xml-body-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250912660,"owners_count":21506865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T22:08:59.343Z","updated_at":"2025-04-25T23:30:29.584Z","avatar_url":"https://github.com/NaturalIntelligence.png","language":"JavaScript","funding_links":["https://opencollective.com/fast-xml-parser/donate","https://paypal.me/naturalintelligence"],"categories":[],"sub_categories":[],"readme":"# fastify-xml-body-parser\nFastify plugin / module to parse XML payload / body into JS object\n\n\u003ca href=\"https://opencollective.com/fast-xml-parser/donate\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://opencollective.com/fast-xml-parser/donate/button@2x.png?color=blue\" width=200 /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://paypal.me/naturalintelligence\"\u003e \u003cimg src=\"static/img/support_paypal.svg\" alt=\"Stubmatic donate button\" width=\"200\"/\u003e\u003c/a\u003e\n\n## Usage\n1. Include in package.json\n```bash\n$npm install fastify-xml-body-parser\n#or\n$yarn add fastify-xml-body-parser\n```\n\n2. Then import in your code and register with fastify\n\n**Sample POST body / payload**\n```\n\u003csample\u003edata\u003c/sample\u003e\n```\n\n```js\n\nconst fastify = require('fastify')()\n\nfastify.register(require('fastify-xml-body-parser'))\n\nfastify.post('/', (req, reply) =\u003e {\n  console.log(req.body.sample)//data\n  reply.send(req.body)\n})\n\nfastify.listen(8000, (err) =\u003e {\n  if (err) throw err\n})\n```\n\nThe sent reply would be the object:\n```js\n{\n  sample: 'data'\n}\n```\n\n## Options\nThis 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.\n\n```js\n\nvar options = {\n  commentPropName: \"#comment\",\n  preserveOrder: true\n};\n\nconst fastify = require('fastify')()\n\nfastify.register(require('fastify-xml-body-parser'), options)\n\n```\n\nAdditionaly, it supports following options\n\n* **validate**: If it is set to `true`, this plugin validate the payload for valid XML syntax before parsing.\n* **contentType**:  It accepts a string or an array of content types. By default it is set to `[\"text/xml\", \"application/xml\", \"application/rss+xml\"]`.\n\n**Note**: I've not included body size limit to this plugin because of following reasons\n* I believe it's good to use API gateway to handle non-functional requirements, like security.\n* There are already some plugins which verifies for body length. It'll be a performance degrade if all the plugins are doing the same thing.\n\n\n## License\n[MIT License](http://jsumners.mit-license.org/)\n\n\n## Our other projects and research you must try\n\n* **[BigBit standard](https://github.com/amitguptagwl/bigbit)** : \n  * Single text encoding to replace UTF-8, UTF-16, UTF-32 and more with less memory.\n  * Single Numeric datatype alternative of integer, float, double, long, decimal and more without precision loss.\n* **[Cytorus](https://github.com/NaturalIntelligence/cytorus)**: Now be specific and flexible while running E2E tests.\n  * Run tests only for a particular User Story\n  * Run tests for a route or from a route\n  * Customizable reporting\n  * Central dashboard for better monitoring\n  * Options to integrate E2E tests with Jira, Github etc using Central dashboard `Tian`.\n* **[Stubmatic](https://github.com/NaturalIntelligence/Stubmatic)** : Create fake webservices, DynamoDB or S3 servers, Manage fake/mock stub data, Or fake/Debug any HTTP(s) call.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalintelligence%2Ffastify-xml-body-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaturalintelligence%2Ffastify-xml-body-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalintelligence%2Ffastify-xml-body-parser/lists"}