Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

refactor: updated types

liyasthomas34fe94215c1e
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 000000000..2a7aa2aad
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,26 @@
+<!--
+Thanks for creating this pull request 🤗
+
+Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one.
+-->
+
+<!-- If this pull request closes an issue, please mention the issue number below -->
+Closes # <!-- Issue # here -->
+
+### Description
+<!-- Add a brief description of the pull request -->
+
+<!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax
+- [ ] Not Completed
+- [x] Completed
+-->
+
+### Checks
+<!-- Make sure your pull request passes the CI checks and do check the following fields as needed - -->
+- [ ] My pull request adheres to the code style of this project
+- [ ] My code requires changes to the documentation
+- [ ] I have updated the documentation as required
+- [ ] All the tests have passed
+
+### Additional Information
+<!-- Any additional information like breaking changes, dependencies added, screenshots, comparisons between new and old behavior, etc. -->
diff --git a/packages/hoppscotch-app/components/collections/ImportExport.vue b/packages/hoppscotch-app/components/collections/ImportExport.vue
index bb1eaf8b2..cefeb23c3 100644
--- a/packages/hoppscotch-app/components/collections/ImportExport.vue
+++ b/packages/hoppscotch-app/components/collections/ImportExport.vue
@@ -178,6 +178,7 @@
<script>
import { defineComponent } from "@nuxtjs/composition-api"
+import { translateToNewRequest } from "@hoppscotch/data"
import { currentUser$ } from "~/helpers/fb/auth"
import * as teamUtils from "~/helpers/teams/utils"
import { useReadonlyStream } from "~/helpers/utils/composables"
@@ -544,7 +545,7 @@ export default defineComponent({
pwRequest.rawParams = request.body.raw
}
}
- return pwRequest
+ return translateToNewRequest(pwRequest)
},
hasFolder(item) {
return Object.prototype.hasOwnProperty.call(item, "item")
diff --git a/packages/hoppscotch-app/newstore/GQLSession.ts b/packages/hoppscotch-app/newstore/GQLSession.ts
index e098dea2e..e9582e4bc 100644
--- a/packages/hoppscotch-app/newstore/GQLSession.ts
+++ b/packages/hoppscotch-app/newstore/GQLSession.ts
@@ -14,7 +14,9 @@ export const defaultGQLSession: GQLSession = {
name: "Untitled request",
url: "https://echo.hoppscotch.io/graphql",
headers: [],
- variables: `{ "id": "1" }`,
+ variables: `{
+ "id": "1"
+}`,
query: `query Request {
method
url
diff --git a/packages/hoppscotch-data/src/rest/index.ts b/packages/hoppscotch-data/src/rest/index.ts
index 9ebb42b49..d3336b43d 100644
--- a/packages/hoppscotch-data/src/rest/index.ts
+++ b/packages/hoppscotch-data/src/rest/index.ts
@@ -88,12 +88,12 @@ export function translateToNewRequest(x: any): HoppRESTRequest {
return x
} else {
// Old format
- const endpoint: string = `${x.url}${x.path}`
+ const endpoint: string = `${x?.url ?? ""}${x?.path ?? ""}`
- const headers: HoppRESTHeader[] = x.headers ?? []
+ const headers: HoppRESTHeader[] = x?.headers ?? []
// Remove old keys from params
- const params: HoppRESTParam[] = (x.params ?? []).map(
+ const params: HoppRESTParam[] = (x?.params ?? []).map(
({
key,
value,
@@ -109,11 +109,11 @@ export function translateToNewRequest(x: any): HoppRESTRequest {
})
)
- const name = x.name
- const method = x.method
+ const name = x?.name ?? "Untitled request"
+ const method = x?.method ?? ""
- const preRequestScript = x.preRequestScript
- const testScript = x.testScript
+ const preRequestScript = x?.preRequestScript ?? ""
+ const testScript = x?.testScript ?? ""
const body = parseRequestBody(x)