{"id":16742788,"url":"https://github.com/yosuke-furukawa/server-timing","last_synced_at":"2025-04-05T07:06:58.358Z","repository":{"id":17182696,"uuid":"81303899","full_name":"yosuke-furukawa/server-timing","owner":"yosuke-furukawa","description":"This module adds [Server-Timing](https://www.w3.org/TR/server-timing/) to response headers, see [example](https://server-timing.now.sh/) and open chrome dev tool","archived":false,"fork":false,"pushed_at":"2024-04-09T08:51:40.000Z","size":591,"stargazers_count":120,"open_issues_count":14,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-15T12:17:35.118Z","etag":null,"topics":["express","nodejs","server-timing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yosuke-furukawa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-02-08T08:03:58.000Z","updated_at":"2024-05-06T21:32:34.791Z","dependencies_parsed_at":"2023-11-07T05:39:10.379Z","dependency_job_id":"48891279-6c87-4f30-92d0-365a748ddade","html_url":"https://github.com/yosuke-furukawa/server-timing","commit_stats":{"total_commits":108,"total_committers":11,"mean_commits":9.818181818181818,"dds":0.5648148148148149,"last_synced_commit":"67914d5d3a00d867526643c4ea6b1ec79d4a5975"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosuke-furukawa%2Fserver-timing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosuke-furukawa%2Fserver-timing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosuke-furukawa%2Fserver-timing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yosuke-furukawa%2Fserver-timing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yosuke-furukawa","download_url":"https://codeload.github.com/yosuke-furukawa/server-timing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"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":["express","nodejs","server-timing"],"created_at":"2024-10-13T01:24:54.996Z","updated_at":"2025-04-05T07:06:58.337Z","avatar_url":"https://github.com/yosuke-furukawa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# server-timing\n\n[![Build Status](https://travis-ci.org/yosuke-furukawa/server-timing.svg?branch=master)](https://travis-ci.org/yosuke-furukawa/server-timing)\n[![Coverage Status](https://coveralls.io/repos/github/yosuke-furukawa/server-timing/badge.svg?branch=improve_coverage)](https://coveralls.io/github/yosuke-furukawa/server-timing?branch=improve_coverage)\n\nThis module adds [Server-Timing](https://www.w3.org/TR/server-timing/) to response headers.\nExample is [here](https://server-timing.now.sh/) and open chrome devtool network tab.\n\nYou can use this as a express module / basic http function.\n\n# Install\n\n```\n$ npm install server-timing -S\n```\n\n# Usage\n\n```javascript\nconst express = require('express');\nconst serverTiming = require('server-timing');\n\nconst app = express();\napp.use(serverTiming());\n\napp.use((req, res, next) =\u003e {\n  res.startTime('file', 'File IO metric');\n  setTimeout(() =\u003e {\n    res.endTime('file');\n  }, 100);\n  next();\n});\napp.use((req, res, next) =\u003e {\n  // you can see test end time response\n  res.startTime('test', 'forget to call endTime');\n  next();\n});\napp.use((req, res, next) =\u003e {\n  // All timings should be in milliseconds (s). See issue #9 (https://github.com/yosuke-furukawa/server-timing/issues/9).\n  res.setMetric('db', 100.0, 'Database metric');\n  res.setMetric('api', 200.0, 'HTTP/API metric');\n  res.setMetric('cache', 300.0, 'cache metric');\n  next();\n});\napp.use((req, res, next) =\u003e {\n  res.send('hello');\n});\n```\n\n## Conditionally enabled\n\n```javascript\nconst express = require('express');\nconst serverTiming = require('server-timing');\n\nconst app = express();\napp.use(serverTiming({\n  // Only send metrics if query parameter `debug` is set to `true`\n  enabled: (req, res) =\u003e req.query.debug === 'true'\n}));\n```\n\n# API\n\n## constructor(options)\n\n- options.name: string, default `total`, name for the timing item\n- options.description: string, default `Total Response Time`, explanation for the timing item\n- options.total: boolean, default `true`, add total response time\n- options.enabled: boolean | function, default `true`, enable server timing header. If a function is passed, it will be called with two arguments, `request` and `response`, and should return a boolean.\n- options.autoEnd: boolean, default `true` automatically endTime is called if timer is not finished.\n- options.precision: number, default `+Infinity`, number of decimals to use for timings.\n\n# Result\n\n![image](https://cloud.githubusercontent.com/assets/555645/22737265/b5b5204e-ee45-11e6-82c5-776a5313d120.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyosuke-furukawa%2Fserver-timing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyosuke-furukawa%2Fserver-timing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyosuke-furukawa%2Fserver-timing/lists"}