1 | |
2 | type Render = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Create project |
7 | * Create a new project. |
8 |
|
9 | */ |
10 | export async function main( |
11 | auth: Render, |
12 | body: { |
13 | name: string |
14 | ownerId: string |
15 | environments: { |
16 | name: string |
17 | protectedStatus?: 'unprotected' | 'protected' |
18 | networkIsolationEnabled?: false | true |
19 | }[] |
20 | } |
21 | ) { |
22 | const url = new URL(`https://api.render.com/v1/projects`) |
23 |
|
24 | const response = await fetch(url, { |
25 | method: 'POST', |
26 | headers: { |
27 | 'Content-Type': 'application/json', |
28 | Authorization: 'Bearer ' + auth.apiKey |
29 | }, |
30 | body: JSON.stringify(body) |
31 | }) |
32 | if (!response.ok) { |
33 | const text = await response.text() |
34 | throw new Error(`${response.status} ${text}`) |
35 | } |
36 | return await response.json() |
37 | } |
38 |
|