{"id":15491554,"url":"https://github.com/diegohaz/bodymen","last_synced_at":"2025-04-13T05:40:32.724Z","repository":{"id":47415599,"uuid":"67518425","full_name":"diegohaz/bodymen","owner":"diegohaz","description":"Body parser middleware for MongoDB, Express and Nodejs (MEN)","archived":false,"fork":false,"pushed_at":"2023-01-23T19:27:39.000Z","size":625,"stargazers_count":47,"open_issues_count":19,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-19T10:05:28.041Z","etag":null,"topics":["body-parser","express","express-middleware","mongodb","mongoose","nodejs","request-body"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diegohaz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-06T14:59:40.000Z","updated_at":"2024-06-04T21:30:32.000Z","dependencies_parsed_at":"2023-01-25T07:46:07.352Z","dependency_job_id":null,"html_url":"https://github.com/diegohaz/bodymen","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fbodymen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fbodymen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fbodymen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegohaz%2Fbodymen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diegohaz","download_url":"https://codeload.github.com/diegohaz/bodymen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670515,"owners_count":21142899,"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":["body-parser","express","express-middleware","mongodb","mongoose","nodejs","request-body"],"created_at":"2024-10-02T07:54:13.465Z","updated_at":"2025-04-13T05:40:32.437Z","avatar_url":"https://github.com/diegohaz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bodymen\n\n[![NPM version][npm-image]][npm-url]\n[![Build Status][travis-image]][travis-url]\n[![Coveralls Status][coveralls-image]][coveralls-url]\n[![Dependency Status][depstat-image]][depstat-url]\n[![Downloads][download-badge]][npm-url]\n\n**Bodymen** works similarly to [Querymen](https://github.com/diegohaz/querymen) and has almost the same functionality, expect it formats, validates and parses request body instead of querystrings. Refer to [Querymen](https://github.com/diegohaz/querymen)'s readme to find out more.\n\n## Prerequisites\n\nYou must use a request body parser like express [body-parser](https://github.com/expressjs/body-parser) and set it up before using bodymen:\n```js\nimport express from 'express'\nimport bodyParser from 'body-parser'\n\nconst app = express()\n\napp.use(bodyParser.urlencoded({ extended: false }))\napp.use(bodyParser.json())\n```\n\n## Install\n\n```sh\nnpm install --save bodymen\n```\n\n## Usage\n\nBodymen allows you to define a schema to control the fields sent through the request body.\n```js\nimport bodymen, { errorHandler } from \"bodymen\"\n\napp.post('/posts', bodymen.middleware({\n  title: {\n    type: String,\n    required: true,\n    trim: true,\n    minlength: 3\n  },\n  content: {\n    type: String,\n    required: true,\n    minlength: 32\n  },\n  tags: [String]\n}), (req, res) =\u003e {\n  console.log(req.bodymen.body) // will contain the parsed body\n})\n\napp.use(errorHandler()) // will send standard error messages, similar to Querymen\n```\n\n## License\n\nMIT © [Diego Haz](http://github.com/diegohaz)\n\n[npm-url]: https://npmjs.org/package/bodymen\n[npm-image]: https://img.shields.io/npm/v/bodymen.svg?style=flat-square\n\n[travis-url]: https://travis-ci.org/diegohaz/bodymen\n[travis-image]: https://img.shields.io/travis/diegohaz/bodymen.svg?style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/diegohaz/bodymen\n[coveralls-image]: https://img.shields.io/coveralls/diegohaz/bodymen.svg?style=flat-square\n\n[depstat-url]: https://david-dm.org/diegohaz/bodymen\n[depstat-image]: https://david-dm.org/diegohaz/bodymen.svg?style=flat-square\n\n[download-badge]: http://img.shields.io/npm/dm/bodymen.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegohaz%2Fbodymen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegohaz%2Fbodymen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegohaz%2Fbodymen/lists"}