From 61d7dcf61b2f98c3c06b5485525e746aab744b6a Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 13 Jan 2020 23:46:31 -0500 Subject: [PATCH 01/97] Added AxiosStrategy and ProxyStrategy Network Strategies --- functions/strategies/AxiosStrategy.js | 8 ++++++++ functions/strategies/ProxyStrategy.js | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 functions/strategies/AxiosStrategy.js create mode 100644 functions/strategies/ProxyStrategy.js diff --git a/functions/strategies/AxiosStrategy.js b/functions/strategies/AxiosStrategy.js new file mode 100644 index 000000000..5c8020784 --- /dev/null +++ b/functions/strategies/AxiosStrategy.js @@ -0,0 +1,8 @@ +import axios from "axios"; + +const axiosStrategy = async (req, _store) => { + const res = await axios(req); + return res; +} + +export default axiosStrategy; diff --git a/functions/strategies/ProxyStrategy.js b/functions/strategies/ProxyStrategy.js new file mode 100644 index 000000000..9cac6f47d --- /dev/null +++ b/functions/strategies/ProxyStrategy.js @@ -0,0 +1,13 @@ +import axios from "axios"; + +const proxyStrategy = async (req, store) => { + const proxyRes = await axios.post( + store.state.postwoman.settings.PROXY_URL || + "https://postwoman.apollotv.xyz/", + req + ); + + return proxyRes.data; +} + +export default proxyStrategy; From 3726f0a376c121c66115a65ce46d29aef39d0e05 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 13 Jan 2020 23:47:28 -0500 Subject: [PATCH 02/97] Added sendNetworkRequest to detect appropriate strategy and use it --- functions/network.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 functions/network.js diff --git a/functions/network.js b/functions/network.js new file mode 100644 index 000000000..f2089363e --- /dev/null +++ b/functions/network.js @@ -0,0 +1,13 @@ +import AxiosStrategy from "./strategies/AxiosStrategy"; +import ProxyStrategy from "./strategies/ProxyStrategy"; + + +const sendNetworkRequest = (req, store) => { + if (store.state.postwoman.settings.PROXY_ENABLED) { + return ProxyStrategy(req, store); + } else { + return AxiosStrategy(req, store); + } +} + +export { sendNetworkRequest }; From 5ef1b5b75c2f6fe76c44eada1613ce623ba8e770 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 13 Jan 2020 23:48:20 -0500 Subject: [PATCH 03/97] Refactor index.vue to use Network Strategies --- pages/index.vue | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index 422b6ade5..9f61a3d6e 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1128,6 +1128,7 @@ import getEnvironmentVariablesFromScript from "../functions/preRequest"; import parseTemplateString from "../functions/templating"; import AceEditor from "../components/ace-editor"; import { tokenRequest, oauthRedirect } from "../assets/js/oauth"; +import { sendNetworkRequest } from "../functions/network"; const statusCategories = [ { @@ -1985,20 +1986,8 @@ export default { if (typeof requestOptions.data === "string") { requestOptions.data = parseTemplateString(requestOptions.data); } - const config = this.$store.state.postwoman.settings.PROXY_ENABLED - ? { - method: "POST", - url: - this.$store.state.postwoman.settings.PROXY_URL || - "https://postwoman.apollotv.xyz/", - data: requestOptions - } - : requestOptions; - const response = await this.$axios(config); - return this.$store.state.postwoman.settings.PROXY_ENABLED - ? response.data - : response; + return await sendNetworkRequest(requestOptions, this.$store); }, async sendRequest() { this.$toast.clear(); From 3a8b4337f0309a167601a35462d81b851b5f7bba Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 13 Jan 2020 23:55:03 -0500 Subject: [PATCH 04/97] Refactor graphql page to use Network Strategies --- pages/graphql.vue | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index 4f21ba2d8..6e66a96e6 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -386,6 +386,7 @@ import axios from "axios"; import * as gql from "graphql"; import textareaAutoHeight from "../directives/textareaAutoHeight"; import AceEditor from "../components/ace-editor"; +import { sendNetworkRequest } from "../functions/network"; export default { directives: { @@ -685,21 +686,7 @@ export default { data: JSON.stringify({ query: gqlQueryString, variables }) }; - const reqConfig = this.$store.state.postwoman.settings.PROXY_ENABLED - ? { - method: "post", - url: - this.$store.state.postwoman.settings.PROXY_URL || - `https://postwoman.apollotv.xyz/`, - data: reqOptions - } - : reqOptions; - - const res = await axios(reqConfig); - - const data = this.$store.state.postwoman.settings.PROXY_ENABLED - ? res.data - : res; + const data = await sendNetworkRequest(reqOptions, this.$store); this.responseString = JSON.stringify(data.data, null, 2); From bd008f42dd358e5ce41d1720fee971d093bb9202 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Tue, 14 Jan 2020 11:49:43 -0500 Subject: [PATCH 05/97] Refactor network and ProxyStrategy code --- functions/network.js | 6 +++--- functions/strategies/ProxyStrategy.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/network.js b/functions/network.js index f2089363e..f4ad8ec66 100644 --- a/functions/network.js +++ b/functions/network.js @@ -5,9 +5,9 @@ import ProxyStrategy from "./strategies/ProxyStrategy"; const sendNetworkRequest = (req, store) => { if (store.state.postwoman.settings.PROXY_ENABLED) { return ProxyStrategy(req, store); - } else { - return AxiosStrategy(req, store); - } + } + + return AxiosStrategy(req, store); } export { sendNetworkRequest }; diff --git a/functions/strategies/ProxyStrategy.js b/functions/strategies/ProxyStrategy.js index 9cac6f47d..f28762d68 100644 --- a/functions/strategies/ProxyStrategy.js +++ b/functions/strategies/ProxyStrategy.js @@ -1,13 +1,13 @@ import axios from "axios"; const proxyStrategy = async (req, store) => { - const proxyRes = await axios.post( + const { data } = await axios.post( store.state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/", req ); - return proxyRes.data; + return data; } export default proxyStrategy; From 061f86fbfa3ee8a074c4e5270be0146507e92033 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Wed, 15 Jan 2020 06:33:04 +0530 Subject: [PATCH 06/97] :bug: Fixed Nuxt loader won't finish after response --- functions/strategies/AxiosStrategy.js | 3 ++- functions/strategies/ProxyStrategy.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/functions/strategies/AxiosStrategy.js b/functions/strategies/AxiosStrategy.js index 5c8020784..de74ec377 100644 --- a/functions/strategies/AxiosStrategy.js +++ b/functions/strategies/AxiosStrategy.js @@ -2,7 +2,8 @@ import axios from "axios"; const axiosStrategy = async (req, _store) => { const res = await axios(req); + window.$nuxt.$loading.finish(); return res; -} +}; export default axiosStrategy; diff --git a/functions/strategies/ProxyStrategy.js b/functions/strategies/ProxyStrategy.js index f28762d68..945482f48 100644 --- a/functions/strategies/ProxyStrategy.js +++ b/functions/strategies/ProxyStrategy.js @@ -3,11 +3,11 @@ import axios from "axios"; const proxyStrategy = async (req, store) => { const { data } = await axios.post( store.state.postwoman.settings.PROXY_URL || - "https://postwoman.apollotv.xyz/", + "https://postwoman.apollotv.xyz/", req ); - + window.$nuxt.$loading.finish(); return data; -} +}; export default proxyStrategy; From 2faf675c0a5d5cd8fa69392e0e85b5d667fb4977 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Wed, 15 Jan 2020 09:10:14 +0530 Subject: [PATCH 07/97] :rotating_light: Removing linter warnings --- components/collections/addCollection.vue | 6 +- components/collections/addFolder.vue | 6 +- components/collections/request.vue | 6 +- components/history.vue | 15 ++-- functions/network.js | 5 +- lang/en-US.js | 12 ++- layouts/error.vue | 6 +- pages/doc.vue | 105 ++++++++++++----------- pages/index.vue | 12 +-- 9 files changed, 99 insertions(+), 74 deletions(-) diff --git a/components/collections/addCollection.vue b/components/collections/addCollection.vue index 197cc412a..2789a52d7 100644 --- a/components/collections/addCollection.vue +++ b/components/collections/addCollection.vue @@ -17,7 +17,11 @@
  • - +
diff --git a/components/collections/addFolder.vue b/components/collections/addFolder.vue index 5601e6f47..1188ad495 100644 --- a/components/collections/addFolder.vue +++ b/components/collections/addFolder.vue @@ -17,7 +17,11 @@
  • - +
diff --git a/components/collections/request.vue b/components/collections/request.vue index b687f0ec3..f96059f12 100644 --- a/components/collections/request.vue +++ b/components/collections/request.vue @@ -1,7 +1,11 @@