{"id":15984493,"url":"https://github.com/metcoder95/fastify-get-head","last_synced_at":"2025-03-18T00:31:25.009Z","repository":{"id":56263469,"uuid":"310122635","full_name":"metcoder95/fastify-get-head","owner":"metcoder95","description":"Fastify plugin to set a HEAD route handler for each GET handler previously registered","archived":false,"fork":false,"pushed_at":"2023-08-25T10:50:20.000Z","size":31,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T21:04:17.222Z","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/metcoder95.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-04T21:33:58.000Z","updated_at":"2023-05-18T21:03:24.000Z","dependencies_parsed_at":"2024-10-27T17:10:32.246Z","dependency_job_id":"236238db-5273-4281-a317-832bcdcdc5d6","html_url":"https://github.com/metcoder95/fastify-get-head","commit_stats":{"total_commits":26,"total_committers":3,"mean_commits":8.666666666666666,"dds":0.2692307692307693,"last_synced_commit":"ecd7746e8f1af933bf8e22b0ca045c903ce8cddf"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metcoder95%2Ffastify-get-head","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metcoder95%2Ffastify-get-head/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metcoder95%2Ffastify-get-head/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metcoder95%2Ffastify-get-head/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metcoder95","download_url":"https://codeload.github.com/metcoder95/fastify-get-head/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243597834,"owners_count":20316844,"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-10-08T02:09:02.704Z","updated_at":"2025-03-18T00:31:24.718Z","avatar_url":"https://github.com/metcoder95.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-get-head\n\n![npm](https://img.shields.io/npm/v/fastify-get-head?color=dark-green\u0026style=flat-square)\n![Build Status](https://github.com/MetCoder95/fastify-get-head/workflows/CI/badge.svg?branch=main)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\nA plugin for [Fastify](http://fastify.io/) that adds support for setting a `HEAD` route for each `GET` one previously registered.\n\nThis plugin's works via Fastify's `onRoute` hook. When a new route is registered, the plugin will try to set a new `HEAD` route if the registered one is for a `GET` method and is not ignored by the `ignorePaths` option.\n\n**Note**: `fastify-get-head` only supports Fastify@\u003e=3.8 \u003c= 3.9\n\n\u003c!-- Will be updated once https://github.com/fastify/fastify/commit/449fc5c25e7d2e277e68bb3f4416cfd858a71cec is released --\u003e\n\n## Example\n\n```js\nconst fastify = require('fastify')();\n\nfastify.register(require('fastify-get-head'), {\n  ignorePaths: ['/api/ignore', /\\/api\\/ignore\\/too/], // For ignoring specific paths\n});\n\nfastify.get('/', (req, reply) =\u003e {\n  reply.status(200).send({ hello: 'world' });\n});\n\n// The plugin will create a new HEAD route where just the headers will be sent\n// Same as doing:\n\n/** \n * fastify.head('/', (req, reply) =\u003e {\n *  reply.headers({\n *    ['content-length']: Buffer.from(JSON.stringify({ hello: 'world' })).byteLength\n *    ['content-type']: 'application/json'\n *  });\n *  reply.status(200).send(null);\n * });\n```\n\n## Options\n\n### ignorePaths\n\nYou're able to use either `string` and `regex` or even the combination of both with the use of an array. This to choose which routes you want to ignore. **Remember that only `GET` routes are taking into consideration**.\n\nExample:\n\n```javascript\nfastify.register(require('fastify-get-head'), {\n  ignorePaths: '/api/ignore', // will ignore just `/api/ignore` path\n});\n\nfastify.register(require('fastify-get-head'), {\n  ignorePaths: /\\/api\\/regex/, // this works as well\n});\n\nfastify.register(require('fastify-get-head'), {\n  ignorePaths: ['/api/ignore', '/api/ignore/string'], // also works\n});\n\nfastify.register(require('fastify-get-head'), {\n  ignorePaths: ['/api/ignore', /\\/api\\/regex/], // this works as well!\n});\n```\n\n## License\n\n[MIT License](https://github.com/MetCoder95/fastify-get-head/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetcoder95%2Ffastify-get-head","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetcoder95%2Ffastify-get-head","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetcoder95%2Ffastify-get-head/lists"}