I am working on a NextJS project and I want to use a github webhook to deploy a script that has deployment instructions.

I have setup a push webhook in github

I tried to add the following code in my server.ts file and for now testing this with ngrok

```
// testing
server.post("/webhooks/github", function(req, res) {
  var sender = req.body.sender;
  var branch = req.body.ref;

  if (branch.indexOf("master") > -1 && sender.login === githubUsername) {
    deploy(res);
  }
});

function deploy(res: any) {
  childProcess.exec("sh deploy.sh", function(err, stdout, stderr) {
    if (err) {
      console.error(err, stderr);
      return res.send(500);
    }
    console.log(stdout);
    res.send(200);
  });
}

```

this file is my node file for the nextJS application

however I am getting a 502 in my ngrok logs

I would like to know where in my NextJS application should I put this webhook endpoint to get it to work