Deletes a package owned by the authenticated user.
1
type Github = {
2
token: string;
3
};
4
/**
5
* Delete a package for the authenticated user
6
* Deletes a package owned by the authenticated user.
7
*/
8
export async function main(
9
auth: Github,
10
package_type: "npm" | "maven" | "rubygems" | "docker" | "nuget" | "container",
11
package_name: string
12
) {
13
const url = new URL(
14
`https://api.github.com/user/packages/${package_type}/${package_name}`
15
);
16
17
const response = await fetch(url, {
18
method: "DELETE",
19
headers: {
20
Authorization: "Bearer " + auth.token,
21
},
22
body: undefined,
23
});
24
if (!response.ok) {
25
const text = await response.text();
26
throw new Error(`${response.status} ${text}`);
27
}
28
return await response.text();
29
30