//native
type Digitalocean = {
token: string;
};
/**
* Create Container Registry
* To create your container registry, send a POST request to `/v2/registry`.
The `name` becomes part of the URL for images stored in the registry. For
example, if your registry is called `example`, an image in it will have the
URL `registry.digitalocean.com/example/image:tag`.
*/
export async function main(
auth: Digitalocean,
body: {
name: string;
subscription_tier_slug: "starter" | "basic" | "professional";
region?: "nyc3" | "sfo3" | "ams3" | "sgp1" | "fra1";
},
) {
const url = new URL(`https://api.digitalocean.com/v2/registry`);
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 536 days ago