{"id":13724942,"url":"https://github.com/fastify/fastify-accepts","last_synced_at":"2025-05-16T07:05:14.677Z","repository":{"id":23029160,"uuid":"97975352","full_name":"fastify/fastify-accepts","owner":"fastify","description":"Add an accepts parser to Fastify","archived":false,"fork":false,"pushed_at":"2025-05-01T13:06:39.000Z","size":170,"stargazers_count":72,"open_issues_count":0,"forks_count":10,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-01T14:23:43.539Z","etag":null,"topics":["accept-header","encoding","fastify","fastify-plugin"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@fastify/accepts","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/fastify.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2017-07-21T18:16:22.000Z","updated_at":"2025-05-01T13:06:36.000Z","dependencies_parsed_at":"2023-10-04T21:14:53.158Z","dependency_job_id":"f569ee8c-b746-486b-adfb-cd1986f06645","html_url":"https://github.com/fastify/fastify-accepts","commit_stats":{"total_commits":194,"total_committers":19,"mean_commits":"10.210526315789474","dds":0.711340206185567,"last_synced_commit":"210a101fb247370718febba3639c4db15610f673"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-accepts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-accepts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-accepts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-accepts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/fastify-accepts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485057,"owners_count":22078767,"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":["accept-header","encoding","fastify","fastify-plugin"],"created_at":"2024-08-03T01:02:07.523Z","updated_at":"2025-05-16T07:05:14.641Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","readme":"# @fastify/accepts\n\n[![CI](https://github.com/fastify/fastify-accepts/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify-accepts/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/accepts.svg?style=flat)](https://www.npmjs.com/package/@fastify/accepts)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nAdd an accepts parser to Fastify.\n\n## Install\n\n`npm i @fastify/accepts`\n\n### Compatibility\n\n| Plugin version | Fastify version |\n| ---------------|-----------------|\n| `\u003e=5.x`        | `^5.x`          |\n| `^4.x`         | `^4.x`          |\n| `\u003e=2.x \u003c4.x`   | `^3.x`          |\n| `^1.x`         | `^2.x`          |\n| `^1.x`         | `^1.x`          |\n\n\nPlease note that if a Fastify version is out of support, then so are the corresponding versions of this plugin\nin the table above.\nSee [Fastify's LTS policy](https://github.com/fastify/fastify/blob/main/docs/Reference/LTS.md) for more details.\n\n## Usage\n\n```js\nconst fastify = require('fastify')\nconst Boom = require('@hapi/boom')\n\nfastify.register(require('@fastify/accepts'))\n\nfastify.post('/', function (req, reply) {\n  const accept = req.accepts() // Accepts object\n  switch(accept.type(['json', 'html'])) {\n    case 'json':\n      reply.type('application/json').send({hello: 'world'})\n      break\n    case 'html':\n      reply.type('text/html').send('\u003cb\u003ehello, world!\u003c/b\u003e')\n      break\n    default:\n      reply.send(Boom.notAcceptable('unacceptable'))\n      break\n  }\n})\n```\n\nSee [accepts package](https://www.npmjs.com/package/accepts) for all available APIs.\n\nThis plugin adds to `Request` object all `Accepts` object methods.\n\n```js\nfastify.post('/', function (req, reply) {\n  req.charset(['utf-8'])\n  req.charsets()\n  req.encoding(['gzip', 'compress'])\n  req.encodings()\n  req.language(['es', 'en'])\n  req.languages()\n  req.type(['image/png', 'image/tiff'])\n  req.types()\n})\n```\n\n### Options\n\n- `decorateReply` If `true`, the `Reply` object will be decorated with the `requestAccepts`, `requestTypes`, `requestCharsets`, `requestEncodings`, and `requestLanguages` methods, which will return the corresponding values from the `Request` object. Default: `false`.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":["\u003ch2 align=\"center\"\u003eAwesome Fastify\u003c/h2\u003e","JavaScript"],"sub_categories":["\u003ch2 align=\"center\"\u003eEcosystem\u003c/h2\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-accepts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ffastify-accepts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-accepts/lists"}