1 | |
2 | type Supabase = { |
3 | key: string |
4 | } |
5 | |
6 | * Create a project |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Supabase, |
11 | body: { |
12 | db_pass: string |
13 | name: string |
14 | organization_id: string |
15 | plan?: 'free' | 'pro' |
16 | region: |
17 | | 'us-east-1' |
18 | | 'us-east-2' |
19 | | 'us-west-1' |
20 | | 'us-west-2' |
21 | | 'ap-east-1' |
22 | | 'ap-southeast-1' |
23 | | 'ap-northeast-1' |
24 | | 'ap-northeast-2' |
25 | | 'ap-southeast-2' |
26 | | 'eu-west-1' |
27 | | 'eu-west-2' |
28 | | 'eu-west-3' |
29 | | 'eu-north-1' |
30 | | 'eu-central-1' |
31 | | 'eu-central-2' |
32 | | 'ca-central-1' |
33 | | 'ap-south-1' |
34 | | 'sa-east-1' |
35 | kps_enabled?: false | true |
36 | desired_instance_size?: |
37 | | 'pico' |
38 | | 'micro' |
39 | | 'small' |
40 | | 'medium' |
41 | | 'large' |
42 | | 'xlarge' |
43 | | '2xlarge' |
44 | | '4xlarge' |
45 | | '8xlarge' |
46 | | '12xlarge' |
47 | | '16xlarge' |
48 | | '24xlarge' |
49 | | '24xlarge_optimized_memory' |
50 | | '24xlarge_optimized_cpu' |
51 | | '24xlarge_high_memory' |
52 | | '48xlarge' |
53 | | '48xlarge_optimized_memory' |
54 | | '48xlarge_optimized_cpu' |
55 | | '48xlarge_high_memory' |
56 | template_url?: string |
57 | } |
58 | ) { |
59 | const url = new URL(`https://api.supabase.com/v1/projects`) |
60 |
|
61 | const response = await fetch(url, { |
62 | method: 'POST', |
63 | headers: { |
64 | 'Content-Type': 'application/json', |
65 | Authorization: 'Bearer ' + auth.key |
66 | }, |
67 | body: JSON.stringify(body) |
68 | }) |
69 | if (!response.ok) { |
70 | const text = await response.text() |
71 | throw new Error(`${response.status} ${text}`) |
72 | } |
73 | return await response.json() |
74 | } |
75 |
|