0

Retrieves list of repositories for a given owner

by
Published Oct 17, 2025

Retrieves repository data for a given owner.

Script sentry Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Retrieves list of repositories for a given owner
4
 * Retrieves repository data for a given owner.
5
 */
6
export async function main(
7
	auth: RT.Sentry,
8
	owner: string,
9
	limit?: string | undefined,
10
	navigation?: string | undefined,
11
	cursor?: string | undefined,
12
	term?: string | undefined
13
) {
14
	const url = new URL(
15
		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/prevent/owner/${owner}/repositories/`
16
	)
17
	for (const [k, v] of [
18
		['limit', limit],
19
		['navigation', navigation],
20
		['cursor', cursor],
21
		['term', term]
22
	]) {
23
		if (v !== undefined && v !== '') {
24
			url.searchParams.append(k, v)
25
		}
26
	}
27
	const response = await fetch(url, {
28
		method: 'GET',
29
		headers: {
30
			Authorization: 'Bearer ' + auth.token
31
		},
32
		body: undefined
33
	})
34
	if (!response.ok) {
35
		const text = await response.text()
36
		throw new Error(`${response.status} ${text}`)
37
	}
38
	return await response.json()
39
}
40