Skip to content

Commit c49f524

Browse files
committed
chore: use FormData
1 parent 918b141 commit c49f524

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/upload.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { readFileSync } from 'node:fs'
55
*/
66
export async function upload({
77
baseUrl = 'https://platform-production-25fb.up.railway.app',
8-
dryRun,
8+
// dryRun,
99
heyApiToken,
1010
pathToOpenApi
1111
}: {
@@ -31,25 +31,29 @@ export async function upload({
3131
throw new Error('invalid OpenAPI path')
3232
}
3333

34-
const formData: Record<string, string | number | boolean> = {
35-
github_repo: process.env.GITHUB_REPOSITORY!,
36-
github_repo_id: process.env.GITHUB_REPOSITORY_ID!,
37-
openapi: data.toString()
38-
}
34+
// const formData: Record<string, string | number | boolean> = {
35+
// github_repo: process.env.GITHUB_REPOSITORY!,
36+
// github_repo_id: process.env.GITHUB_REPOSITORY_ID!,
37+
// openapi: data.toString()
38+
// }
3939

40-
if (dryRun) {
41-
formData['dry-run'] = dryRun
42-
}
40+
const formData = new FormData();
41+
42+
formData.set('spec', data.toString());
43+
44+
// if (dryRun) {
45+
// formData['dry-run'] = dryRun
46+
// }
4347

44-
const body = Object.entries(formData)
45-
.flatMap(
46-
([key, value]) =>
47-
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
48-
)
49-
.join('&')
48+
// const body = Object.entries(formData)
49+
// .flatMap(
50+
// ([key, value]) =>
51+
// `${encodeURIComponent(key)}=${encodeURIComponent(value)}`
52+
// )
53+
// .join('&')
5054

5155
const response = await fetch(`${baseUrl}/v1/specs`, {
52-
body,
56+
body: formData,
5357
headers: {
5458
Authorization: `Bearer ${heyApiToken}`,
5559
'Content-Type': 'multipart/form-data'

0 commit comments

Comments
 (0)