diff --git a/components/ui/js-editor.vue b/components/ui/js-editor.vue new file mode 100644 index 00000000..f0d488e4 --- /dev/null +++ b/components/ui/js-editor.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/helpers/preRequest.js b/helpers/preRequest.js index dc5ba9a9..6375fece 100644 --- a/helpers/preRequest.js +++ b/helpers/preRequest.js @@ -1,20 +1,22 @@ export default function getEnvironmentVariablesFromScript(script) { let _variables = {} - // the pw object is the proxy by which pre-request scripts can pass variables to the request. - // for security and control purposes, this is the only way a pre-request script should modify variables. - let pw = { - environment: { - set: (key, value) => (_variables[key] = value), - }, - env: { - set: (key, value) => (_variables[key] = value), - }, - // globals that the script is allowed to have access to. - } + try { + // the pw object is the proxy by which pre-request scripts can pass variables to the request. + // for security and control purposes, this is the only way a pre-request script should modify variables. + let pw = { + environment: { + set: (key, value) => (_variables[key] = value), + }, + env: { + set: (key, value) => (_variables[key] = value), + }, + // globals that the script is allowed to have access to. + } - // run pre-request script within this function so that it has access to the pw object. - new Function("pw", script)(pw) + // run pre-request script within this function so that it has access to the pw object. + new Function("pw", script)(pw) + } catch (_e) {} return _variables } diff --git a/package.json b/package.json index 88fad4a8..c88e7e05 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@nuxtjs/toast": "^3.3.1", "ace-builds": "^1.4.12", "firebase": "^7.17.1", + "esprima": "^4.0.1", "graphql": "^15.3.0", "graphql-language-service-interface": "^2.4.0", "nuxt": "^2.12.2", diff --git a/pages/index.vue b/pages/index.vue index 971f2085..b1763e18 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -821,9 +821,8 @@ - import("~/components/collections"), saveRequestAs: () => import("~/components/collections/saveRequestAs"), Editor: AceEditor, + JSEditor: JSEditor, environments: () => import("~/components/environments"), inputform: () => import("~/components/firebase/inputform"), notes: () => import("~/components/firebase/feeds"),