Edits history of script submission #18426 for ' List database deploys (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * List database deploys
     * By default it returns the 20 last results. The response is paginated.
     */
    export async function main(auth: RT.Qovery, databaseId: string, pageSize?: string | undefined) {
    	const url = new URL(`https://api.qovery.com/database/${databaseId}/deploymentHistoryV2`)
    	for (const [k, v] of [['pageSize', pageSize]]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Token ' + 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