https://github.com/shutterstock/node-timing-middleware
Expose request timing in express apps
https://github.com/shutterstock/node-timing-middleware
middleware monitoring performance timing
Last synced: 11 months ago
JSON representation
Expose request timing in express apps
- Host: GitHub
- URL: https://github.com/shutterstock/node-timing-middleware
- Owner: shutterstock
- License: mit
- Created: 2014-04-25T17:24:03.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-11-29T21:19:31.000Z (over 8 years ago)
- Last Synced: 2025-06-14T16:04:20.250Z (about 1 year ago)
- Topics: middleware, monitoring, performance, timing
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 5
- Watchers: 41
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# node-timing-middleware
Expose request times to do with as you desire: statsd, log, etc.
[](http://travis-ci.org/shutterstock/node-timing-middleware)
## Caveats
Works with any express 2+, but express versions 4+ will not return a correct path if:
* routes are nested
* middleware responds to a request rather than a route handler
## Example usage
```javascript
var timing = require('timing-middleware');
var express = require('express');
var app = express();
app.use(timing(function(verb, path, duration, req, res) {
console.log(verb, path, "took", duration, "ms and returned ", res.statusCode);
}));
app.get('/fairly_slow_route', function(req, res, next) {
setTimeout(function() {
res.send('ok!\n');
}, 10);
});
```
## License
[MIT](LICENSE) © 2014-2017 Shutterstock Images, LLC