This module can add `ServerTiming` Header to http response, and be able to use express middleware
npm install server-timing

This module adds Server-Timing to response headers.
Example is here and open chrome devtool network tab.
You can use this as a express module / basic http function.
```
$ npm install server-timing -S
`javascript
const express = require('express');
const serverTiming = require('server-timing');
const app = express();
app.use(serverTiming());
app.use((req, res, next) => {
res.startTime('file', 'File IO metric');
setTimeout(() => {
res.endTime('file');
}, 100);
next();
});
app.use((req, res, next) => {
// you can see test end time response
res.startTime('test', 'forget to call endTime');
next();
});
app.use((req, res, next) => {
// All timings should be in milliseconds (s). See issue #9 (https://github.com/yosuke-furukawa/server-timing/issues/9).
res.setMetric('db', 100.0, 'Database metric');
res.setMetric('api', 200.0, 'HTTP/API metric');
res.setMetric('cache', 300.0, 'cache metric');
next();
});
app.use((req, res, next) => {
res.send('hello');
});
`
`javascript
const express = require('express');
const serverTiming = require('server-timing');
const app = express();
app.use(serverTiming({
// Only send metrics if query parameter debug is set to true`
enabled: (req, res) => req.query.debug === 'true'
}));
- options.name: string, default total, name for the timing itemTotal Response Time
- options.description: string, default , explanation for the timing itemtrue
- options.total: boolean, default , add total response timetrue
- options.enabled: boolean | function, default , enable server timing header. If a function is passed, it will be called with two arguments, request and response, and should return a boolean.true
- options.autoEnd: boolean, default automatically endTime is called if timer is not finished.+Infinity`, number of decimals to use for timings.
- options.precision: number, default