refactor: init newstore for request body

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
liyasthomas
2021-08-14 14:31:16 +05:30
parent e9eee0703d
commit a129d7eb13
4 changed files with 188 additions and 128 deletions

View File

@@ -15,12 +15,23 @@ export type HoppRESTHeader = {
active: boolean
}
export type HoppRESTReqBody = {
contentType: ValidContentTypes
body: string
isRaw: boolean
export type FormDataKeyValue = {
key: string
active: boolean
} & ({ isFile: true; value: Blob } | { isFile: false; value: string })
export type HoppRESTReqBodyFormData = {
contentType: "multipart/form-data"
body: FormDataKeyValue[]
}
export type HoppRESTReqBody =
| {
contentType: Exclude<ValidContentTypes, "multipart/form-data">
body: string
}
| HoppRESTReqBodyFormData
export interface HoppRESTRequest {
v: string
@@ -55,14 +66,12 @@ function parseRequestBody(x: any): HoppRESTReqBody {
return {
contentType: "application/json",
body: x.rawParams,
isRaw: x.rawInput,
}
}
return {
contentType: "application/json",
body: "",
isRaw: x.rawInput,
}
}