type Bitbucket = {
username: string;
password: string;
};
/**
* Get a webhook resource
* Returns the webhook resource or subject types on which webhooks can
be registered.
Each resource/subject type contains an `events` link that returns the
paginated list of specific events each individual subject type can
emit.
This endpoint is publicly accessible and does not require
authentication or scopes.
*/
export async function main(auth: Bitbucket) {
const url = new URL(`https://api.bitbucket.org/2.0/hook_events`);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 470 days ago