If we want to measure the total time taken for each route in an Express server, we can do so by adding a common middleware that tracks the time elapsed between the moment a request comes and before the response is sent back.
Calling the above two endpoints would log
index.js is the entrypoint to our server and that’s usually the place where all the common middlewares are added. The
logResponseTime middleware needs to be at the top because we want to be as accurate as possible when we measure the time taken for each route in our Express server. The process.hrtime api is used to measure the elapsed time as it is more accurate than just using the