{"_id":"express-simple-timing","_rev":"142-738b839267c5f315276715b66c6138d9","name":"express-simple-timing","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"express-simple-timing","version":"1.0.0","license":"Apache-2.0","_id":"express-simple-timing@1.0.0","maintainers":[{"name":"damouse404","email":"chris.sidebottom@bbc.co.uk"}],"homepage":"https://github.com/bbc/express-simple-timing#readme","bugs":{"url":"https://github.com/bbc/express-simple-timing/issues"},"dist":{"shasum":"385c1045e12e434fe7a8b44fcc8f6012058f5b4e","tarball":"https://registry.npmjs.org/express-simple-timing/-/express-simple-timing-1.0.0.tgz","fileCount":6,"integrity":"sha512-ySb6CNTVJBRlUJajNSYKQP2e+jdCtSsSV+lXkOR6K+GfAkndjvpNl0p9nHukUCzmi/cHi7vWyjCM7ctb0HfLYg==","signatures":[{"sig":"MEUCICVoe8ppTLWAm6xTzsY+OruieHZ0NabEmGusTleOHCRFAiEAkDJLEiijLynmlJw/To88xoF4yri6tAeQNBvWjhpKYZA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7468},"main":"index.js","gitHead":"6de89224e0125524f58ed2212c445a4b7540d571","scripts":{"lint":"eslint .","test":"mocha","coverage":"istanbul cover _mocha -- -R dot","posttest":"npm run lint"},"_npmUser":{"name":"damouse404","email":"chris.sidebottom@bbc.co.uk"},"repository":{"url":"git+https://github.com/bbc/express-simple-timing.git","type":"git"},"_npmVersion":"5.6.0","description":"Express middleware that sends Server-Timing stats for routes","directories":{},"_nodeVersion":"8.9.4","dependencies":{"on-headers":"^1.0.1"},"eslintConfig":{"extends":"iplayer-es6"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^5.0.4","sinon":"^4.4.5","eslint":"^4.18.2","express":"^4.16.3","istanbul":"^0.4.5","supertest":"^3.0.0","eslint-config-iplayer-es6":"^4.0.1"},"_npmOperationalInternal":{"tmp":"tmp/express-simple-timing_1.0.0_1521196208819_0.6775613597348213","host":"s3://npm-registry-packages"}}},"time":{"created":"2018-03-16T10:30:08.818Z","modified":"2026-09-27T07:16:03.831Z","1.0.0":"2018-03-16T10:30:08.879Z"},"bugs":{"url":"https://github.com/bbc/express-simple-timing/issues"},"license":"Apache-2.0","homepage":"https://github.com/bbc/express-simple-timing#readme","repository":{"url":"git+https://github.com/bbc/express-simple-timing.git","type":"git"},"description":"Express middleware that sends Server-Timing stats for routes","maintainers":[{"email":"nisaanth.manegavasar@bbc.co.uk","name":"mknish"},{"email":"sam.bason@bbc.co.uk","name":"sbason"},{"email":"abdullahiob@proton.me","name":"abz.me"},{"email":"henry.warne@bbc.co.uk","name":"henrywarne"},{"email":"paul.caporn@bbc.co.uk","name":"caporp01"},{"email":"swati.tabib@bbc.co.uk","name":"swatitabib"},{"email":"ian.arundale@bbc.co.uk","name":"ianarundale"},{"email":"andy.harris.01@bbc.co.uk","name":"andycharris"},{"email":"joseph.carre@bbc.co.uk","name":"carrejoe3"},{"email":"chiha.choi@bbc.co.uk","name":"chibbc"},{"email":"ajit.rajakumar@bbc.co.uk","name":"ajitsanto09"},{"email":"mohammad.alcheikhmousa@bbc.co.uk","name":"yusuf963m"},{"email":"priya.ramkumar@bbc.co.uk","name":"ramkup01"},{"email":"indu.aggarwal@bbc.co.uk","name":"aggari01"},{"email":"james.brown03@bbc.co.uk","name":"jamesmmbrown"},{"email":"james.dodd@gmail.com","name":"jamesdesq"},{"email":"ridwan.arshad@bbc.co.uk","name":"riddles_dev"},{"email":"iplayerwebdevelopers@bbc.co.uk","name":"iplayer-web-jenkins"},{"email":"chris.kay01@bbc.co.uk","name":"chris-kay"},{"email":"piyusha.shah.ext@bbc.co.uk","name":"shahp07"},{"email":"roopashree.ramachandraiah@bbc.co.uk","name":"roopashree-ramachandraiah"},{"email":"matt.stephenson@bbc.co.uk","name":"mstephensonbbc"},{"email":"joseph.pack@bbc.co.uk","name":"joearo"},{"email":"martin.reilly@bbc.co.uk","name":"bbcmarr"},{"email":"ajitsantossh0995@gmail.com","name":"ajsanto09"},{"email":"catherine.hooper@bbc.co.uk","name":"catherine_hpr"},{"email":"ridwan.arshad90@gmail.com","name":"ridwan_dev"},{"email":"antoine.rabanes@bbc.co.uk","name":"antoinerabanesbbc"},{"email":"vasanthi.rudramuni@bbc.co.uk","name":"rudrav01"},{"email":"chris.sidebottom@bbc.co.uk","name":"damouse404"}],"readme":"# express-simple-timing\n\n> [Express](http://expressjs.com/) middleware that sets Server Timing API headers and optionally sends timers to stats systems.\n\n`express-simple-timing` returns a middleware function that can be used with an [express](http://expressjs.com/) server. It sends `Server-Timing` headers to the client to allow inspection of route timings. It can also send stats to your stats system by using a callback passed into the constructor.\n\nA default key of `total` is created based on the total time to deliver the entire route.\n\n## Installation\n\n```\nnpm install --save express-simple-timing\n```\n\n## Example Usage\n\n````js\nconst simpleTiming = require('express-simple-timing');\nconst router = require('express').Router();\n\nrouter.use(simpleTiming());\n\nmodule.exports = router.put('/mypath', function(req, res) {\n  res.json({\n    message: 'my response'\n  });\n});\n````\n\nThis will add a total value by default, such as:\n\n```\nserver-timing: total;dur=4.043\n```\n\n### Custom metrics\n\nBy using the `serverTimingStart` and `serverTimingEnd` methods you can send ad hoc metrics for your app:\n\n```\nres.serverTimingStart('woof');\nbarkLikeADog();\nres.serverTimingEnd('woof');\n```\n\nThis will then add an additional timing header:\n\n```\nserver-timing: woof;dur=2.43\n```\n\n### Stats Callback\n\nTo use the timing metrics in your own stats system, you can pass a callback which receives `req`, `key` and `value` every time a server-timing header is added.\n\n````js\nconst myStats = require('my-stats-system');\nconst simpleTiming = require('express-simple-timing');\nconst router = require('express').Router();\n\nfunction myStatsHook(req, key, value) {\n  myStats(req.url, key, value);\n}\n\nrouter.use(simpleTiming(myStatsHook));\n````\n\n## Test\n\n```\nnpm test\n```\n","readmeFilename":"README.md"}