Search code examples
node.jsexpressresponse

NodeJs route execution time


every time i do an http request to any route in my app i got in my console the route method , execution time and and anther number that i have no idea what it means(will love to know) . enter image description here

does anyone know how can i use this data? i want to record routes that takes more then x time so i can improve those routes.

i try do find from console. in the express framework as i assumed its coming from there but no luck


Solution

  • As I can see from the screenshot, you're probably using morgan middleware.

    By default it logs all the requests in the dev format which is -

    :method :url :status :response-time ms - :res[content-length]
    

    So according to your screenshot -

    1. Patch is the method.
    2. /trades/ is the url path.
    3. 200 is the status code.
    4. 5.893 is the response time.
    5. 2 is content length of the response.

    I think you were asking about content length. It's basically the size of your response body in bytes.