//native
type Render = {
apiKey: string
}
/**
* List custom domains
* List a particular service's custom domains that match the provided filters. If no filters are provided, all custom domains for the service are returned.
*/
export async function main(
auth: Render,
serviceId: string,
cursor: string | undefined,
limit: string | undefined,
name: string | undefined,
domainType: 'apex' | 'subdomain' | undefined,
verificationStatus: 'verified' | 'unverified' | undefined,
createdBefore: string | undefined,
createdAfter: string | undefined
) {
const url = new URL(`https://api.render.com/v1/services/${serviceId}/custom-domains`)
for (const [k, v] of [
['cursor', cursor],
['limit', limit],
['name', name],
['domainType', domainType],
['verificationStatus', verificationStatus],
['createdBefore', createdBefore],
['createdAfter', createdAfter]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago