{"id":14969160,"url":"https://github.com/fastify/fastify-diagnostics-channel","last_synced_at":"2025-10-19T09:32:28.841Z","repository":{"id":38069749,"uuid":"315382767","full_name":"fastify/fastify-diagnostics-channel","owner":"fastify","description":"Plugin to deal with diagnostics_channel on Fastify","archived":false,"fork":false,"pushed_at":"2024-10-01T16:05:45.000Z","size":92,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-10-03T02:33:47.399Z","etag":null,"topics":["fastify","fastify-plugin"],"latest_commit_sha":null,"homepage":null,"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/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},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2020-11-23T16:58:36.000Z","updated_at":"2024-10-01T16:05:46.000Z","dependencies_parsed_at":"2024-01-23T20:11:26.702Z","dependency_job_id":"bf8dafe2-f9d7-4538-825a-fe1a3c7291f9","html_url":"https://github.com/fastify/fastify-diagnostics-channel","commit_stats":{"total_commits":102,"total_committers":12,"mean_commits":8.5,"dds":0.6862745098039216,"last_synced_commit":"4a2b6b0bb373d38d81eb98a33e375586238e6359"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":"fastify/skeleton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-diagnostics-channel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-diagnostics-channel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-diagnostics-channel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-diagnostics-channel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/fastify-diagnostics-channel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869246,"owners_count":16555572,"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":["fastify","fastify-plugin"],"created_at":"2024-09-24T13:41:15.124Z","updated_at":"2025-10-19T09:32:23.614Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","readme":"# @fastify/diagnostics-channel\n\n![CI](https://github.com/fastify/fastify-diagnostics-channel/workflows/CI/badge.svg)\n[![NPM version](https://img.shields.io/npm/v/@fastify/diagnostics-channel.svg?style=flat)](https://www.npmjs.com/package/@fastify/diagnostics-channel)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n\n## Install\n```sh\nnpm i @fastify/diagnostics-channel\n```\n\n## Usage\n\nRegister as a plugin. This will add some hooks that provide information through [`diagnostics_channel`](https://nodejs.org/api/diagnostics_channel.html)\n\n```js\nconst fastify = require('fastify')()\n\nfastify.register(require('@fastify/diagnostics-channel'), {})\n```\n\n_**Note**: check [examples/](./examples/index.js) to further information_\n\n## What information is provided?\n\n1. [onRoute Channel](#onroute-channel)\n2. [onResponse Channel](#onresponse-channel)\n3. [onError Channel](#onerror-channel)\n4. [onTimeout Channel](#ontimeout-channel)\n4. [onRequest Channel](#onrequest-channel)\n\nThe channels are prefixed by: `fastify.{HOOK_NAME}`\n\n### onRoute Channel\n\n**Channel**: `fastify.onRoute`\n\nThis event is sent at every route registered passing a `routeOptions` object\n\n```js\nconst dc = require('node:diagnostics_channel')\nconst onRoute = dc.channel('fastify.onRoute')\n\nonRoute.subscribe((routeOptions) =\u003e {\n  routeOptions.method\n  routeOptions.schema\n  routeOptions.url // the complete URL of the route, it will inclued the prefix if any\n  routeOptions.path // `url` alias\n  routeOptions.routePath // the URL of the route without the prefix\n  routeOptions.bodyLimit\n  routeOptions.logLevel\n  routeOptions.logSerializers\n  routeOptions.prefix\n})\n```\n\n### onResponse Channel\n\n**Channel**: `fastify.onResponse`\n\nThis event is sent at every response sent by server, it propagates an object containing: [`request` object](https://fastify.dev/docs/latest/Reference/Request) and [`reply` object](https://fastify.dev/docs/latest/Reference/Reply)\n\n```js\nconst dc = require('node:diagnostics_channel')\nconst onResponse = dc.channel('fastify.onResponse')\n\nonResponse.subscribe((data) =\u003e {\n  data.request\n  data.reply\n})\n```\n\n### onError Channel\n\n**Channel**: `fastify.onError`\n\nThis event is sent when some error is throw on the [lifecycle](https://fastify.dev/docs/latest/Reference/Lifecycle/) of Fastify.\n\nThe message data is an object containing a [`request` object](https://fastify.dev/docs/latest/Reference/Request), [`reply` object](https://fastify.dev/docs/latest/Reference/Reply), and Error object\n\n```js\nconst dc = require('node:diagnostics_channel')\nconst onError = dc.channel('fastify.onError')\n\nonError.subscribe((data) =\u003e {\n  data.request\n  data.reply\n  data.error // error object throwed\n})\n```\n\n### onTimeout Channel\n\n**Channel**: `fastify.onTimeout`\n\nThis event is sent when a request spent more time than [`connectionTimeout`](https://fastify.dev/docs/latest/Reference/Server/#connectiontimeout) specifies. For further information about `connectionTimeout` check the Fastify documentation.\n\nThe message data is an object containing a [`request` object](https://fastify.dev/docs/latest/Reference/Request), [`reply` object](https://fastify.dev/docs/latest/Reference/Reply), and `connectionTimeout` value\n\nNote: by default the Fastify does not limit the request time.\n\n```js\nconst dc = require('node:diagnostics_channel')\nconst onTimeout = dc.channel('fastify.onTimeout')\n\nonTimeout.subscribe((data) =\u003e {\n  data.connectionTimeout\n  data.reply\n  data.request\n})\n```\n\n### onRequest Channel\n\n**Channel**: `fastify.onRequest`\n\nThis event is sent when a request is received; the message data is an object containing a [`request` object](https://fastify.dev/docs/latest/Reference/Request) and [`reply` object](https://fastify.dev/docs/latest/Reference/Reply)\n\n```js\nconst dc = require('node:diagnostics_channel')\nconst onRequest = dc.channel('fastify.onRequest')\n\nonRequest.subscribe((data) =\u003e {\n  data.request\n  data.reply\n})\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-diagnostics-channel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ffastify-diagnostics-channel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-diagnostics-channel/lists"}