expressjs / response-time Goto Github PK
View Code? Open in Web Editor NEWResponse time header for node.js
License: MIT License
Response time header for node.js
License: MIT License
This is definitely debatable, but in my opinion, X-Response-Time header should be added to the Access-Control-Expose-Headers
header. My rationale for this is that if somebody is using this package, they are explicitly asking you to expose the X-Response-Time
header, therefore, you need to explicitly tell the browser that this header is safe. This can be done with one line of code:
res.header('Access-Control-Expose-Headers', 'X-Response-Time');
Hey,
I was using response-time as a methodology to obtain metric on all the node module accesses and the server time used by each call. In order for ease of access, the handler that processes response-time is embedded into load event handler for all XMLHTTPRequests.
However, the XMLHTTPRequests implementation lacks information about which URL the response came from, which was strange.
I'm suggesting that response-time return a JSON object like thus:
this.setHeader('X-Response-Time', '{"url":"'+req.url+'","time":"'+ ms.toFixed(digits) + '"}');
Would this be more preferable or am I approaching this the wrong way?
Hi,
When using the responseTime(fn) it throws some errors.
app.use(responseTime((req: Request, res: Response, time: any)
Argument of type '(req: Request, res: Response, time: any) => void' is not assignable to parameter of type 'ResponseTimeFunction'.
Types of parameters 'req' and 'request' are incompatible.
Type 'IncomingMessage' is not assignable to type 'Request'.
Property 'get' is missing in type 'IncomingMessage'.
And you cannot add a nextFunction.
This post gives the overview of the advantages of Server Timing and how to use it.
I think we can provide an option to use this header instead for sending response time.
The request-received
middleware at https://github.com/cabinjs/request-received exposes a Symbol.for
property, which this package could conditionally consume if interested (as opposed to just generating process.hrtime()
.
e.g. https://github.com/expressjs/response-time/blob/master/index.js#L53 would change from var startAt = process.hrtime()
to var startAt = req[Symbol.for('request-received.startAt')] ? req[Symbol.for('request-received.startAt')] : process.hrtime()
Hi,
Why is the response time of the attached header X-Response-Time
different from the response time of the responseTime(req, res, time)
which are both different to the response time in postman for a get request.
Version: 2.3.2
(!) Use of eval is strongly discouraged
https://rollupjs.org/guide/en/#avoiding-eval
../../../node_modules/response-time/node_modules/depd/index.js
408:
409: // eslint-disable-next-line no-eval
410: var deprecatedfn = eval('(function (' + args + ') {\n' +
^
411: '"use strict"\n' +
412: 'log.call(deprecate, message, site)\n' +
I want to use this module to calculate the response times, but don't want to send back a header. Instead, I want to provide a callback that will be called when the response time is calculated so I can then store this in a stats db/tracker.
Thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.