Include meaningful User-Agent header in requests to the GitHub UI

This adds a custom `User-Agent` header to requests from the
GitHub server to the GitHub API, identifying the application,
the version and key information about the environment.

This aligns with the [recommendations][1] in the GitHub Docs.

As part of this change, I have also moved the current version of
the server into a constant, and fix the initialization of `Server`
to use that version, taking from `package.json`.

[1]: https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#user-agent
This commit is contained in:
Tim Rogers
2025-02-02 15:01:16 +00:00
parent 0f7730209d
commit df63442c3c
4 changed files with 11 additions and 3 deletions

View File

@@ -23,6 +23,7 @@
"@types/node": "^22",
"@types/node-fetch": "^2.6.12",
"node-fetch": "^3.3.2",
"universal-user-agent": "^7.0.2",
"zod": "^3.22.4",
"zod-to-json-schema": "^3.23.5"
},
@@ -30,4 +31,4 @@
"shx": "^0.3.4",
"typescript": "^5.6.2"
}
}
}