//native
type Vercel = {
token: string;
};
/**
* List git repositories linked to namespace by provider
* Lists git repositories linked to a namespace `id` for a supported provider. A specific namespace `id` can be obtained via the `git-namespaces` endpoint. Supported providers are `github`, `gitlab` and `bitbucket`. If the provider or namespace is not provided, it will try to obtain it from the user that authenticated the request.
*/
export async function main(
auth: Vercel,
query: string | undefined,
namespaceId: string | undefined,
provider:
| "github"
| "github-custom-host"
| "gitlab"
| "bitbucket"
| undefined,
installationId: string | undefined,
host: string | undefined,
teamId: string | undefined,
slug: string | undefined,
) {
const url = new URL(`https://api.vercel.com/v1/integrations/search-repo`);
for (const [k, v] of [
["query", query],
["namespaceId", namespaceId],
["provider", provider],
["installationId", installationId],
["host", host],
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago