//native
type Render = {
apiKey: string
}
/**
* Update redirect/rewrite rule priority
* Update the priority for a particular redirect/rewrite rule.
To apply redirect/rewrite rules to an incoming request, Render starts from the rule with priority `0` and applies the first encountered rule that matches the request's path (if any).
Render increments the priority of other rules by `1` as necessary to make space for the updated rule.
*/
export async function main(auth: Render, serviceId: string, body: { priority: number }) {
const url = new URL(`https://api.render.com/v1/services/${serviceId}/routes`)
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
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 235 days ago