0

List Audit Logs

by
Published Sep 27, 2024

Return the audit logs for the given organization, ordered by the created_at field in descending order.

Script turso Verified

The script

Submitted by hugo697 Bun
Verified 620 days ago
1
//native
2
type Turso = {
3
	apiToken: string
4
}
5

6
export async function main(resource: Turso, organizationSlug: string) {
7
	const endpoint = `https://api.turso.tech/v1/organizations/${organizationSlug}/audit-logs`
8

9
	const response = await fetch(endpoint, {
10
		method: 'GET',
11
		headers: {
12
			Authorization: `Bearer ${resource.apiToken}`
13
		}
14
	})
15

16
	if (!response.ok) {
17
		throw new Error(`HTTP error! status: ${response.status}`)
18
	}
19

20
	const data = await response.json()
21

22
	return data.plans
23
}
24