Edits history of script submission #18714 for ' Scale instance count (render)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Render = {
    	apiKey: string
    }
    /**
     * Scale instance count
     * [Scale](https://docs.render.com/scaling#manual-scaling) the service with the provided ID to a fixed number of instances.
    
    Render ignores this value as long as autoscaling is enabled for the service.
    
     */
    export async function main(auth: Render, serviceId: string, body: { numInstances: number }) {
    	const url = new URL(`https://api.render.com/v1/services/${serviceId}/scale`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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.text()
    }
    

    Submitted by hugo697 235 days ago