1 | |
2 | |
3 | * Create a branch |
4 | * Create a new branch in your ReadMe project. |
5 |
|
6 | >📘 |
7 | > This route is only available to projects that are using [ReadMe Refactored](https://docs.readme.com/main/docs/welcome-to-readme-refactored). |
8 | */ |
9 | export async function main(auth: RT.Readme, body: Body) { |
10 | const url = new URL(`https://api.readme.com/v2/branches`) |
11 |
|
12 | const response = await fetch(url, { |
13 | method: 'POST', |
14 | headers: { |
15 | 'Content-Type': 'application/json', |
16 | Authorization: 'Bearer ' + auth.apiKey |
17 | }, |
18 | body: JSON.stringify(body) |
19 | }) |
20 | if (!response.ok) { |
21 | const text = await response.text() |
22 | throw new Error(`${response.status} ${text}`) |
23 | } |
24 | return await response.json() |
25 | } |
26 |
|
27 | |
28 | |
29 | * This file was automatically generated by json-schema-to-typescript. |
30 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
31 | * and run json-schema-to-typescript to regenerate this file. |
32 | */ |
33 |
|
34 | export type Body = |
35 | | { |
36 | |
37 | * The clean string of version we are basing off of. |
38 | */ |
39 | base: string |
40 | |
41 | * A non-semver display name for the version. |
42 | */ |
43 | display_name?: string |
44 | |
45 | * The semver name for the version. |
46 | */ |
47 | name: string |
48 | privacy?: { |
49 | |
50 | * Whether the version is public, hidden, or the stable version that's visible by default. |
51 | */ |
52 | view?: 'default' | 'hidden' | 'public' |
53 | } |
54 | |
55 | * Whether the version is released or in beta. |
56 | */ |
57 | release_stage?: 'beta' | 'release' |
58 | |
59 | * Whether the version is current or deprecated. |
60 | */ |
61 | state?: 'current' | 'deprecated' |
62 | } |
63 | | { |
64 | |
65 | * The name of the branch. |
66 | */ |
67 | name: string |
68 | } |
69 |
|