diff --git a/packages/server/src/api/controllers/query/import/index.ts b/packages/server/src/api/controllers/query/import/index.ts index c99d89c2de..933d6b101c 100644 --- a/packages/server/src/api/controllers/query/import/index.ts +++ b/packages/server/src/api/controllers/query/import/index.ts @@ -3,7 +3,7 @@ import { queryValidation } from "../validation" import { generateQueryID } from "../../../../db/utils" import { ImportInfo, ImportSource } from "./sources/base" import { OpenAPI2 } from "./sources/openapi2" -import { Query } from './../../../../definitions/common'; +import { Query } from "./../../../../definitions/common" import { Curl } from "./sources/curl" interface ImportResult { errorQueries: Query[] diff --git a/packages/server/src/api/controllers/query/import/sources/curl.ts b/packages/server/src/api/controllers/query/import/sources/curl.ts index ae580f65e5..61e1ae0215 100644 --- a/packages/server/src/api/controllers/query/import/sources/curl.ts +++ b/packages/server/src/api/controllers/query/import/sources/curl.ts @@ -29,7 +29,7 @@ const parseBody = (curl: any) => { } const parseCookie = (curl: any) => { - if (curl.cookies){ + if (curl.cookies) { return Object.entries(curl.cookies).reduce((acc, entry) => { const [key, value] = entry return acc + `${key}=${value}; ` diff --git a/packages/server/src/integrations/base/IntegrationBase.ts b/packages/server/src/integrations/base/IntegrationBase.ts index d87a98c73b..bfda4fbd4d 100644 --- a/packages/server/src/integrations/base/IntegrationBase.ts +++ b/packages/server/src/integrations/base/IntegrationBase.ts @@ -1,6 +1,6 @@ export interface IntegrationBase { - create?(query: any): Promise - read?(query: any): Promise - update?(query: any): Promise - delete?(query: any): Promise + create?(query: any): Promise + read?(query: any): Promise + update?(query: any): Promise + delete?(query: any): Promise } diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index 582bbc5ad9..bba3c87d68 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -115,7 +115,9 @@ module RestModule { data = await response.text() raw = data } - const size = formatBytes(response.headers.get("content-length") || Buffer.byteLength(raw, "utf8")) + const size = formatBytes( + response.headers.get("content-length") || Buffer.byteLength(raw, "utf8") + ) const time = `${Math.round(performance.now() - this.startTimeMs)}ms` headers = response.headers.raw() for (let [key, value] of Object.entries(headers)) { @@ -148,7 +150,15 @@ module RestModule { } async _req(query: RestQuery) { - const { path = "", queryString = "", headers = {}, method = "GET", disabledHeaders, bodyType, requestBody } = query + const { + path = "", + queryString = "", + headers = {}, + method = "GET", + disabledHeaders, + bodyType, + requestBody, + } = query this.headers = { ...this.config.defaultHeaders, ...headers, @@ -166,15 +176,25 @@ module RestModule { if (requestBody) { switch (bodyType) { case BodyTypes.TEXT: - const text = typeof requestBody !== "string" ? JSON.stringify(requestBody) : requestBody + const text = + typeof requestBody !== "string" + ? JSON.stringify(requestBody) + : requestBody + // content type defaults to plaintext input.body = text break - default: case BodyTypes.JSON: + default: + case BodyTypes.JSON: try { // confirm its json const json = JSON.parse(requestBody) - if (json && typeof json === "object" && Object.keys(json).length > 0) { + if ( + json && + typeof json === "object" && + Object.keys(json).length > 0 + ) { input.body = requestBody + input.headers["Content-Type"] = "application/json" } } catch (err) { throw "Invalid JSON for request body"