-
Notifications
You must be signed in to change notification settings - Fork 0
fix: ensure x-app-uuid is present when using token #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,13 @@ export class HTTPResponseError extends Error { | |
*/ | ||
export class HttpRequestUtil { | ||
async request(url: string, opts: any, json = true) { | ||
const response = await fetch(url, opts); | ||
const defaultOpts = { | ||
headers: { | ||
"User-Agent": `heroku-applink-node-sdk/1.0`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: we should be able to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This bends my brain a bit - just using something like: const pjson = fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8");
const pkg = JSON.parse(pjson);
const defaultOpts = {
headers: {
"User-Agent": `heroku-applink-node-sdk/${pkg.version}`,
},
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I forget __dirname isn't available in modules and have to do some hackery. |
||
}, | ||
}; | ||
|
||
const response = await fetch(url, { ...defaultOpts, ...opts }); | ||
|
||
if (!response.ok) { | ||
throw new HTTPResponseError(response); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, why use a branded type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a Go habit of declaring "this thing really is a UUID instead of literally any string"