//native
type Supabase = {
key: string
}
/**
* Bulk update functions
* Bulk update functions. It will create a new function or replace existing. The operation is idempotent. NOTE: You will need to manually bump the version.
*/
export async function main(
auth: Supabase,
ref: string,
body: {
id: string
slug: string
name: string
status: 'ACTIVE' | 'REMOVED' | 'THROTTLED'
version: number
created_at?: number
verify_jwt?: false | true
import_map?: false | true
entrypoint_path?: string
import_map_path?: string
}[]
) {
const url = new URL(`https://api.supabase.com/v1/projects/${ref}/functions`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.key
},
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 154 days ago