//native
type Supabase = {
key: string
}
/**
* Update database branch config
* Updates the configuration of the specified database branch
*/
export async function main(
auth: Supabase,
branch_id: string,
body: {
branch_name?: string
git_branch?: string
reset_on_push?: false | true
persistent?: false | true
status?:
| 'CREATING_PROJECT'
| 'RUNNING_MIGRATIONS'
| 'MIGRATIONS_PASSED'
| 'MIGRATIONS_FAILED'
| 'FUNCTIONS_DEPLOYED'
| 'FUNCTIONS_FAILED'
}
) {
const url = new URL(`https://api.supabase.com/v1/branches/${branch_id}`)
const response = await fetch(url, {
method: 'PATCH',
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 207 days ago