Search code examples
javascriptnode.jsexpressserverbackend

Get the number of Requests in Express


I would like to know if is there any way of getting the total number of request in a certain path with Expressjs?


Solution

  • Why not to count it by yourself?

    let pingCount = 0;
    app.get('/ping',(req, res) => {
      pingCount++;
      res.send(`ping world for ${pingCount} times`);
    });