1 | |
2 | type Netlify = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update site dev server hook |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Netlify, |
11 | site_id: string, |
12 | id: string, |
13 | body: { |
14 | title?: string; |
15 | branch?: string; |
16 | type?: "new_dev_server" | "content_refresh"; |
17 | }, |
18 | ) { |
19 | const url = new URL( |
20 | `https://api.netlify.com/api/v1/sites/${site_id}/dev_server_hooks/${id}`, |
21 | ); |
22 |
|
23 | const response = await fetch(url, { |
24 | method: "PUT", |
25 | headers: { |
26 | "Content-Type": "application/json", |
27 | Authorization: "Bearer " + auth.token, |
28 | }, |
29 | body: JSON.stringify(body), |
30 | }); |
31 | if (!response.ok) { |
32 | const text = await response.text(); |
33 | throw new Error(`${response.status} ${text}`); |
34 | } |
35 | return await response.json(); |
36 | } |
37 |
|