{"id":16768303,"url":"https://github.com/zenmate/stats","last_synced_at":"2025-10-16T13:25:52.600Z","repository":{"id":57170548,"uuid":"150739749","full_name":"zenmate/stats","owner":"zenmate","description":":bar_chart: Request statistics middleware","archived":false,"fork":false,"pushed_at":"2019-05-02T07:32:21.000Z","size":283,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-08-09T00:45:12.736Z","etag":null,"topics":["expressjs","middleware","node","nodejs","statistics","stats"],"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/zenmate.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}},"created_at":"2018-09-28T12:49:15.000Z","updated_at":"2024-04-29T19:15:32.000Z","dependencies_parsed_at":"2022-08-27T12:02:06.074Z","dependency_job_id":null,"html_url":"https://github.com/zenmate/stats","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zenmate/stats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmate%2Fstats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmate%2Fstats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmate%2Fstats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmate%2Fstats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenmate","download_url":"https://codeload.github.com/zenmate/stats/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmate%2Fstats/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272965380,"owners_count":25023066,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["expressjs","middleware","node","nodejs","statistics","stats"],"created_at":"2024-10-13T06:11:14.628Z","updated_at":"2025-10-16T13:25:47.567Z","avatar_url":"https://github.com/zenmate.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stats\n\n\u003e Request statistics middleware\n\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n## Installation\n\n```bash\nnpm i @zenmate/stats\n```\n\n## API\n\n```js\nconst initStats = require('@zenmate/stats');\nconst { statsMiddleware, getStats } = initStats({ endpointStats: true });\n```\n\n### initStats([options])\n\nReturns `statsMiddleware` middleware function and `getStats` function,\nthat returns current stats\n\n#### Options\n\n`initStats` accepts optional `options` object that may contain any of the following keys:\n\n##### endpointStats\n\nDefaults to `false`\n\nBoolean that indicates wether to track per endpoint stats.\n\n**Not recommended** for complex applications and applications\nthat have endpoints like `/user/123`\n\n\n## Example\n\nHere is the example of usage in express app\n\n```js\nconst app = require('express')();\nconst initStats = require('@zenmate/stats');\n\nconst { statsMiddleware, getStats } = initStats({ endpointStats: true });\n\napp.use(statsMiddleware);\napp.get('/', (req,res) =\u003e res.end('Hello'));\napp.get('/stats', (req,res) =\u003e res.send(getStats()));\n\napp.listen(8080);\nconsole.log('Server listens at http://localhost:8080');\n```\n\nVisiting http://localhost:8080/stats will give following result:\n\n```json\n{\n  \"uptime\": 10485,\n  \"statusCodes\": {\n    \"200\": 6,\n    \"404\": 1\n  },\n  \"uuid\": \"b6797718-eb11-48e4-941f-8348ccf8d9ed\",\n  \"pid\": 20797,\n  \"totalTime\": 10.537291,\n  \"averageTime\": 1.5053272857142856,\n  \"count\": 7,\n  \"endpointStats\": {\n    \"GET /\": {\n      \"totalTime\": 7.486513999999999,\n      \"averageTime\": 1.2477523333333331,\n      \"count\": 6,\n      \"statusCodes\": {\n        \"200\": 6\n      }\n    },\n    \"GET /favicon.ico\": {\n      \"totalTime\": 3.050777,\n      \"averageTime\": 3.050777,\n      \"count\": 1,\n      \"statusCodes\": {\n        \"404\": 1\n      }\n    }\n  }\n}\n```\n\nAll time related results are in milliseconds\n\n\n# [License](LICENSE)\n\n# Inspired by\n[`expressjs/response-time`](https://github.com/expressjs/response-time) and [`thoas/stats`](https://github.com/thoas/stats)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenmate%2Fstats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenmate%2Fstats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenmate%2Fstats/lists"}