Edits history of script submission #20857 for ' Create a project (supabase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Supabase = {
    	key: string
    }
    /**
     * Create a project
     *
     */
    export async function main(
    	auth: Supabase,
    	body: {
    		db_pass: string
    		name: string
    		organization_id: string
    		plan?: 'free' | 'pro'
    		region:
    			| 'us-east-1'
    			| 'us-east-2'
    			| 'us-west-1'
    			| 'us-west-2'
    			| 'ap-east-1'
    			| 'ap-southeast-1'
    			| 'ap-northeast-1'
    			| 'ap-northeast-2'
    			| 'ap-southeast-2'
    			| 'eu-west-1'
    			| 'eu-west-2'
    			| 'eu-west-3'
    			| 'eu-north-1'
    			| 'eu-central-1'
    			| 'eu-central-2'
    			| 'ca-central-1'
    			| 'ap-south-1'
    			| 'sa-east-1'
    		kps_enabled?: false | true
    		desired_instance_size?:
    			| 'pico'
    			| 'micro'
    			| 'small'
    			| 'medium'
    			| 'large'
    			| 'xlarge'
    			| '2xlarge'
    			| '4xlarge'
    			| '8xlarge'
    			| '12xlarge'
    			| '16xlarge'
    			| '24xlarge'
    			| '24xlarge_optimized_memory'
    			| '24xlarge_optimized_cpu'
    			| '24xlarge_high_memory'
    			| '48xlarge'
    			| '48xlarge_optimized_memory'
    			| '48xlarge_optimized_cpu'
    			| '48xlarge_high_memory'
    		template_url?: string
    	}
    ) {
    	const url = new URL(`https://api.supabase.com/v1/projects`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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 235 days ago