{"id":15699063,"url":"https://github.com/eomm/fastify-405","last_synced_at":"2025-05-06T21:07:51.737Z","repository":{"id":34244309,"uuid":"173344183","full_name":"Eomm/fastify-405","owner":"Eomm","description":"Add 405 HTTP status to your routes","archived":false,"fork":false,"pushed_at":"2025-02-24T17:37:59.000Z","size":43,"stargazers_count":6,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-06T21:07:38.822Z","etag":null,"topics":["405","fastify","fastify-plugin","hacktoberfest","http-status-code"],"latest_commit_sha":null,"homepage":"","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/Eomm.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},"funding":{"github":"Eomm"}},"created_at":"2019-03-01T17:43:31.000Z","updated_at":"2024-11-25T17:12:51.000Z","dependencies_parsed_at":"2023-12-18T19:47:24.163Z","dependency_job_id":"5219d028-0278-47bc-84a5-98a245b1439d","html_url":"https://github.com/Eomm/fastify-405","commit_stats":{"total_commits":30,"total_committers":5,"mean_commits":6.0,"dds":0.5333333333333333,"last_synced_commit":"e77ddec8cfdc4b4d0d1b89787179e3d6822cdc56"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-405","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-405/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-405/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-405/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eomm","download_url":"https://codeload.github.com/Eomm/fastify-405/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252769420,"owners_count":21801378,"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":["405","fastify","fastify-plugin","hacktoberfest","http-status-code"],"created_at":"2024-10-03T19:37:56.271Z","updated_at":"2025-05-06T21:07:51.716Z","avatar_url":"https://github.com/Eomm.png","language":"JavaScript","readme":"# fastify-405\n\n[![ci](https://github.com/Eomm/fastify-405/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Eomm/fastify-405/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/fastify-405)](https://www.npmjs.com/package/fastify-405)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\nAdd 405 Method Not Allowed HTTP status to your routes, instead of the default 404.\n\n\n## Install\n\n```\nnpm install fastify-405\n```\n\n### Compatible\n\n| Plugin version | Fastify version |\n| ------------- |:---------------:|\n| `^4.0.0` | `^5.0.0` |\n| `^3.0.0` | `^4.0.0` |\n| `^2.0.0` | `^3.2.0` |\n| `^1.0.0` | `^2.0.0` |\n\n\n## Usage\n\nRegister the plugin with some custom option.\nIt will add an `onRoute` hook and will add an handler\nthat replay with HTTP status 405 and the `allow` response header.\n\nThe `allow` header will contains what you define in the options.\n\nThis plugin has been tested also with the encapsulation!\n\n```js\nimport Fastify from 'fastify'\n\nconst fastify = Fastify()\nawait fastify.register(import('fastify-405'), {\n  regexp: /\\/foo.*/,\n  allow: ['GET', 'HEAD']\n})\n\n// This route will reply 405 on POST, HEAD, OPTIONS, PUT..\nfastify.get('/foo', (req, reply) =\u003e {\n  reply.send({ hello: 'world' })\n})\n\n// This route will not match the fastify-405 regexp and will reply with 404 on other HTTP methods\nfastify.get('/bar', (req, reply) =\u003e {\n  reply.send({ hello: 'world' })\n})\n\nawait fastify.listen({ port: 3000 })\nconsole.log('Server listening at http://localhost:3000')\n```\n\n\u003e **Note**\n\u003e You need to `await` the plugin registration to make sure the plugin is ready to use.\n\u003e All the routes defined **before** the plugin registration will be ignored.\n\u003e This change has been introduced in Fastify v4.\n\n### Options\n\nYou can pass the following options during the registration:\n\n| Option | Default | Description |\n|--------|---------|-------------|\n|`regexp`| `/.*/`  | The regular expression the route must fulfil in order to add the 405 handler\n|`allow` | `['GET', 'POST']` | The method that the route will allow, the HTTP methods that are not in this array will reply 405\n\n```js\nawait fastify.register(require('fastify-405'), {\n  regexp: /\\/foo.*/, // must be a regular expression\n  allow: ['GET', 'POST'] // could be only a subset of: ['GET', 'POST', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'PATCH']\n})\n```\n\n\n## License\n\nCopyright [Manuel Spigolon](https://github.com/Eomm), Licensed under [MIT](./LICENSE).\n","funding_links":["https://github.com/sponsors/Eomm"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feomm%2Ffastify-405","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feomm%2Ffastify-405","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feomm%2Ffastify-405/lists"}