@stepzen/graphiql-proxy 0.21.0-beta.1 → 0.21.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stepzen/graphiql-proxy",
3
- "version": "0.21.0-beta.1",
3
+ "version": "0.21.0-beta.2",
4
4
  "author": "Darren Waddell <darren@stepzen.com>",
5
5
  "license": "MIT",
6
6
  "homepage": "https://stepzen.com",
@@ -57,5 +57,5 @@
57
57
  "sinon-chai": "3.7.0",
58
58
  "ts-node": "^10.8.2"
59
59
  },
60
- "gitHead": "6dddebabddbbd69adb07b5e7c816125ae5dc3430"
60
+ "gitHead": "58b85cc37fa990639bf7170d4224cf51cc1f7ad1"
61
61
  }
@@ -1,9 +1,9 @@
1
1
  // Copyright (c) 2020,2021,2022, StepZen, Inc.
2
2
 
3
3
  const details = async (req, res) => {
4
- const {account, domain, predicates, workspace} = req.stepzen
4
+ const {zenservUrl, predicates, workspace} = req.stepzen
5
5
 
6
- const endpoint = `https://${account}.${domain}/${workspace.endpoint}/__graphql`
6
+ const endpoint = `${zenservUrl}/${workspace.endpoint}/__graphql`
7
7
 
8
8
  res.json({
9
9
  endpoint,
@@ -6,22 +6,32 @@ const fetch = require('node-fetch')
6
6
  const {version} = require('../../../package.json')
7
7
 
8
8
  const proxy = async (req, res) => {
9
- const {account, adminkey, debugging, domain, predicates, workspace} =
10
- req.stepzen
9
+ const {
10
+ adminkey,
11
+ debugging,
12
+ zenservDomain,
13
+ zenservUrl,
14
+ predicates,
15
+ workspace,
16
+ } = req.stepzen
11
17
 
12
18
  let endpoint = workspace.endpoint
13
19
 
14
- let headers = {}
20
+ let headers = {
21
+ host: zenservDomain,
22
+ }
15
23
 
16
24
  if (predicates.available && predicates.enabled) {
17
25
  try {
18
26
  const others = JSON.parse(JSON.stringify(predicates.headers))
19
27
  headers = {
28
+ ...headers,
20
29
  ...others,
21
30
  }
22
31
  } catch {}
23
32
  } else {
24
33
  headers = {
34
+ ...headers,
25
35
  Authorization: `Apikey ${adminkey}`,
26
36
  }
27
37
  }
@@ -33,10 +43,7 @@ const proxy = async (req, res) => {
33
43
  }
34
44
  }
35
45
 
36
- const url = `https://${account}.${domain.replace(
37
- '.io',
38
- '.net',
39
- )}/${endpoint}/__graphql`
46
+ const url = `${zenservUrl}/${endpoint}/__graphql`
40
47
 
41
48
  debug('stepzen:dashboard')(`proxy headers: ${JSON.stringify(headers)}`)
42
49
  debug('stepzen:dashboard')(`proxy url: ${url}`)
@@ -15,24 +15,41 @@ const _predicates = require('./api/predicates')
15
15
  const proxy = require('./api/proxy')
16
16
  const samples = require('./api/samples')
17
17
 
18
- module.exports = async ({
19
- account,
20
- adminkey,
21
- apikey,
22
- cli = {version: ''},
23
- domain = 'stepzen.io',
24
- port = 5000,
25
- predicates = {
26
- available: false,
27
- enabled: false,
28
- onTogglePredicates: async () => {},
29
- },
30
- debugging = {
31
- enabled: false,
32
- onToggleDebugging: async () => {},
33
- },
34
- workspace,
35
- }) => {
18
+ module.exports = async options => {
19
+ const {
20
+ /** @deprecated use zenservDomain and zenservUrl */
21
+ account,
22
+ adminkey,
23
+ apikey,
24
+ cli = {version: ''},
25
+ /** @deprecated use zenservDomain and zenservUrl */
26
+ domain = 'stepzen.io',
27
+ port = 5000,
28
+ predicates = {
29
+ available: false,
30
+ enabled: false,
31
+ onTogglePredicates: async () => {},
32
+ },
33
+ debugging = {
34
+ enabled: false,
35
+ onToggleDebugging: async () => {},
36
+ },
37
+ workspace,
38
+ zenservDomain,
39
+ zenservUrl,
40
+ } = options
41
+
42
+ const warnIfUsingDeprecatedOption = option => {
43
+ if (options[option]) {
44
+ debug('stepzen:dashboard')(
45
+ `The account ${option} is deprecated.` +
46
+ ` Please use zenservDomain and zenservUrl instead.`,
47
+ )
48
+ }
49
+ }
50
+ warnIfUsingDeprecatedOption('account')
51
+ warnIfUsingDeprecatedOption('domain')
52
+
36
53
  const app = express()
37
54
 
38
55
  app.use(express.json())
@@ -41,14 +58,16 @@ module.exports = async ({
41
58
  app.use(express.static(`${__dirname}/../ui/build`))
42
59
  app.use((req, res, next) => {
43
60
  req.stepzen = {
44
- account,
45
61
  adminkey,
46
62
  apikey,
47
63
  cli,
48
64
  debugging,
49
- domain,
50
65
  predicates,
51
66
  workspace,
67
+ zenservDomain:
68
+ zenservDomain || `${account}.${domain.replace('.io', '.net')}`,
69
+ zenservUrl:
70
+ zenservUrl || `https://${account}.${domain.replace('.io', '.net')}`,
52
71
  }
53
72
  next()
54
73
  })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "/static/css/main.4fb42d49.css",
4
- "main.js": "/static/js/main.58ea6b6f.js",
4
+ "main.js": "/static/js/main.6e3668a7.js",
5
5
  "static/js/503.a3ba392a.chunk.js": "/static/js/503.a3ba392a.chunk.js",
6
6
  "static/js/136.7849911c.chunk.js": "/static/js/136.7849911c.chunk.js",
7
7
  "static/js/190.e088a175.chunk.js": "/static/js/190.e088a175.chunk.js",
@@ -27,7 +27,7 @@
27
27
  "static/media/logo.svg": "/static/media/logo.2fa5e016c31f1c335b07ff477d91ee9a.svg",
28
28
  "index.html": "/index.html",
29
29
  "main.4fb42d49.css.map": "/static/css/main.4fb42d49.css.map",
30
- "main.58ea6b6f.js.map": "/static/js/main.58ea6b6f.js.map",
30
+ "main.6e3668a7.js.map": "/static/js/main.6e3668a7.js.map",
31
31
  "503.a3ba392a.chunk.js.map": "/static/js/503.a3ba392a.chunk.js.map",
32
32
  "136.7849911c.chunk.js.map": "/static/js/136.7849911c.chunk.js.map",
33
33
  "190.e088a175.chunk.js.map": "/static/js/190.e088a175.chunk.js.map",
@@ -53,6 +53,6 @@
53
53
  },
54
54
  "entrypoints": [
55
55
  "static/css/main.4fb42d49.css",
56
- "static/js/main.58ea6b6f.js"
56
+ "static/js/main.6e3668a7.js"
57
57
  ]
58
58
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>StepZen</title><script defer="defer" src="/static/js/main.58ea6b6f.js"></script><link href="/static/css/main.4fb42d49.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>StepZen</title><script defer="defer" src="/static/js/main.6e3668a7.js"></script><link href="/static/css/main.4fb42d49.css" rel="stylesheet"></head><body><div id="root"></div></body></html>