type Github = {
token: string;
};
/**
* Create an autolink reference for a repository
* Users with admin access to the repository can create an autolink.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
body: {
is_alphanumeric?: boolean & string;
key_prefix: string;
url_template: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/autolinks`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* Create an autolink reference for a repository
* Users with admin access to the repository can create an autolink.
*/
export async function main(
auth: Github,
owner: string,
repo: string,
body: {
is_alphanumeric?: boolean & string;
key_prefix: string;
url_template: string;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/autolinks`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 927 days ago