-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: http body;perf: create by json;perf: create by curl (#3570)
* perf: http body * feat: create app by json (#3557) * feat: create app by json * fix build * perf: create by json;perf: create by curl * fix: ts --------- Co-authored-by: heheer <[email protected]>
- Loading branch information
1 parent
f1f0ae2
commit d0d1a2c
Showing
34 changed files
with
1,276 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import parse from '@bany/curl-to-json'; | ||
|
||
type RequestMethod = 'get' | 'post' | 'put' | 'delete' | 'patch'; | ||
const methodMap: { [K in RequestMethod]: string } = { | ||
get: 'GET', | ||
post: 'POST', | ||
put: 'PUT', | ||
delete: 'DELETE', | ||
patch: 'PATCH' | ||
}; | ||
|
||
export const parseCurl = (curlContent: string) => { | ||
const parsed = parse(curlContent); | ||
|
||
if (!parsed.url) { | ||
throw new Error('url not found'); | ||
} | ||
|
||
const newParams = Object.keys(parsed.params || {}).map((key) => ({ | ||
key, | ||
value: parsed.params?.[key], | ||
type: 'string' | ||
})); | ||
const newHeaders = Object.keys(parsed.header || {}).map((key) => ({ | ||
key, | ||
value: parsed.header?.[key], | ||
type: 'string' | ||
})); | ||
const newBody = JSON.stringify(parsed.data, null, 2); | ||
|
||
return { | ||
url: parsed.url, | ||
method: methodMap[parsed.method?.toLowerCase() as RequestMethod] || 'GET', | ||
params: newParams, | ||
headers: newHeaders, | ||
body: newBody | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/web/components/common/Icon/icons/core/app/type/jsonImport.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.