@domoinc/ryuu-proxy 4.3.3 → 4.3.4-beta.1
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/README.md +63 -18
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# ryuu-proxy
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.org/package/@domoinc/ryuu-proxy)
|
|
4
|
+
[](https://packagephobia.com/result?p=@domoinc/ryuu-proxy)
|
|
5
|
+
[](https://npm-stat.com/charts.html?package=@domoinc/ryuu)
|
|
6
|
+
[](https://snyk.io/test/npm/@domoinc/ryuu-proxy)
|
|
7
|
+
|
|
3
8
|
Simple middleware to add to a local development server while developing Domo Apps. The middleware will intercept any calls to `/data/v{d}`, `/sql/v{d}`, `/dql/v{d}` or `/domo/.../v{d}`, proxy an authenticated request to the Domo App service, and pipe the response back so that you can develop your Domo App locally and still get request data from Domo.
|
|
4
9
|
|
|
5
10
|
## Installation
|
|
@@ -17,9 +22,10 @@ $ domo login
|
|
|
17
22
|
```
|
|
18
23
|
|
|
19
24
|
### Configuration
|
|
25
|
+
|
|
20
26
|
```js
|
|
21
|
-
const { Proxy } = require(
|
|
22
|
-
const manifest = require(
|
|
27
|
+
const { Proxy } = require("@domoinc/ryuu-proxy");
|
|
28
|
+
const manifest = require("./path/to/app/manifest.json");
|
|
23
29
|
|
|
24
30
|
const config = { manifest };
|
|
25
31
|
|
|
@@ -28,15 +34,18 @@ const proxy = new Proxy(config);
|
|
|
28
34
|
```
|
|
29
35
|
|
|
30
36
|
The proxy constructor expects a `config` object. Certain properties are required and others are optional.
|
|
37
|
+
|
|
31
38
|
#### Required Configuration Properties
|
|
39
|
+
|
|
32
40
|
- `manifest`: The parsed contents of a project's manifest.json file. `domo publish` have been run at least once to ensure the `manifest.json` file has an `id` property
|
|
33
41
|
|
|
34
42
|
#### Optional Configuration Properties
|
|
43
|
+
|
|
35
44
|
- `manifest.proxyId`: An advanced property required for projects leveraging DQL, writebacks, or Oauth. If you are unsure of whether or not you need this, you most likely don't. To get a proxyId, see "Getting a proxyId" below
|
|
36
45
|
|
|
37
46
|
### With [Express](https://expressjs.com/) / [Connect](https://github.com/senchalabs/connect)
|
|
38
47
|
|
|
39
|
-
This library comes with a simple wrapper for Express/Connect middleware.
|
|
48
|
+
This library comes with a simple wrapper for Express/Connect middleware.
|
|
40
49
|
|
|
41
50
|
```js
|
|
42
51
|
const app = express();
|
|
@@ -52,7 +61,7 @@ For other frameworks, the library exposes the necessary functions to create a st
|
|
|
52
61
|
app.use(async (ctx, next) => {
|
|
53
62
|
await proxy
|
|
54
63
|
.stream(ctx.req)
|
|
55
|
-
.then(data => ctx.body = ctx.req.pipe(data))
|
|
64
|
+
.then((data) => (ctx.body = ctx.req.pipe(data)))
|
|
56
65
|
.catch(next);
|
|
57
66
|
});
|
|
58
67
|
```
|
|
@@ -62,7 +71,7 @@ app.use(async (ctx, next) => {
|
|
|
62
71
|
app.use((req, res, next) => {
|
|
63
72
|
proxy
|
|
64
73
|
.stream(req)
|
|
65
|
-
.then(stream => stream.pipe(res))
|
|
74
|
+
.then((stream) => stream.pipe(res))
|
|
66
75
|
.catch(() => next());
|
|
67
76
|
});
|
|
68
77
|
```
|
|
@@ -70,12 +79,10 @@ app.use((req, res, next) => {
|
|
|
70
79
|
```js
|
|
71
80
|
// node http
|
|
72
81
|
const server = http.createServer((req, res) => {
|
|
73
|
-
if (req.url ===
|
|
82
|
+
if (req.url === "/") {
|
|
74
83
|
loadHomePage(res);
|
|
75
84
|
} else {
|
|
76
|
-
proxy
|
|
77
|
-
.stream(req)
|
|
78
|
-
.then(stream => stream.pipe(res));
|
|
85
|
+
proxy.stream(req).then((stream) => stream.pipe(res));
|
|
79
86
|
}
|
|
80
87
|
});
|
|
81
88
|
```
|
|
@@ -89,9 +96,9 @@ Ignoring the errors will cause the proxy to fail silently and the proxy request
|
|
|
89
96
|
app.use(async (ctx, next) => {
|
|
90
97
|
await proxy
|
|
91
98
|
.stream(ctx.req)
|
|
92
|
-
.then(data => ctx.body = ctx.req.pipe(data))
|
|
99
|
+
.then((data) => (ctx.body = ctx.req.pipe(data)))
|
|
93
100
|
.catch((err) => {
|
|
94
|
-
if (err.name ===
|
|
101
|
+
if (err.name === "DomoException") {
|
|
95
102
|
ctx.status = err.status || err.statusCode || 500;
|
|
96
103
|
ctx.body = err;
|
|
97
104
|
} else {
|
|
@@ -106,9 +113,9 @@ app.use(async (ctx, next) => {
|
|
|
106
113
|
app.use((req, res, next) => {
|
|
107
114
|
proxy
|
|
108
115
|
.stream(req)
|
|
109
|
-
.then(stream => stream.pipe(res))
|
|
110
|
-
.catch(err => {
|
|
111
|
-
if (err.name ===
|
|
116
|
+
.then((stream) => stream.pipe(res))
|
|
117
|
+
.catch((err) => {
|
|
118
|
+
if (err.name === "DomoException") {
|
|
112
119
|
res.status(err.status || err.statusCode || 500).json(err);
|
|
113
120
|
} else {
|
|
114
121
|
next();
|
|
@@ -120,14 +127,14 @@ app.use((req, res, next) => {
|
|
|
120
127
|
```js
|
|
121
128
|
// http
|
|
122
129
|
const server = http.createServer((req, res) => {
|
|
123
|
-
if (req.url ===
|
|
130
|
+
if (req.url === "/") {
|
|
124
131
|
loadHomePage();
|
|
125
132
|
} else {
|
|
126
133
|
proxy
|
|
127
134
|
.stream(req)
|
|
128
|
-
.then(stream => stream.pipe(res))
|
|
129
|
-
.catch(err => {
|
|
130
|
-
if (err.name ===
|
|
135
|
+
.then((stream) => stream.pipe(res))
|
|
136
|
+
.catch((err) => {
|
|
137
|
+
if (err.name === "DomoException") {
|
|
131
138
|
res.writeHead(err.status || err.statusCode || 500);
|
|
132
139
|
res.end(JSON.stringify(err));
|
|
133
140
|
}
|
|
@@ -137,7 +144,9 @@ const server = http.createServer((req, res) => {
|
|
|
137
144
|
```
|
|
138
145
|
|
|
139
146
|
## Getting a proxyId (Advanced)
|
|
147
|
+
|
|
140
148
|
Apps using DQL, writeback, or oAuth features are required to supply an proxyId as part of the proxy configuration. This allows the proxy to know how to properly route requests. The proxyId can be found as part of the URL for the iframe in which your app is displayed. It will be of the form `XXXXXXXX-XXXX-4XXX-XXXX-XXXXXXXXXXXX`. To find the ID:
|
|
149
|
+
|
|
141
150
|
1. Make sure the app has been published at least once with `domo publish`
|
|
142
151
|
2. Publish a new card based on your app design, or navigate to an existing card made from your app design
|
|
143
152
|
3. Right-click anywhere in the card and choose "Inspect element"
|
|
@@ -145,3 +154,39 @@ Apps using DQL, writeback, or oAuth features are required to supply an proxyId a
|
|
|
145
154
|
5. Copy the ID found between `//` and `.domoapps`. That is your app's `proxyId`
|
|
146
155
|
|
|
147
156
|
`proxyId`s tie apps to cards. If you delete the card from which you retrieved the proxyId, you will have to get a new one from another card created from your app design.
|
|
157
|
+
|
|
158
|
+
## Building
|
|
159
|
+
|
|
160
|
+
To build ryuu-proxy, run
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npm run build
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
All necessary files will be built/copied into the `dist` folder.
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
### Recommended Workflow:
|
|
171
|
+
|
|
172
|
+
1. Create new branch (named "DOMO-XXXXXX")
|
|
173
|
+
2. Make Changes
|
|
174
|
+
3. Commit Changes
|
|
175
|
+
4. Test changes (if necessary, version a alpha/beta/tagged version, then release it)
|
|
176
|
+
5. Make pull request
|
|
177
|
+
6. After pull request is merged to master, bump version, then release it to npm
|
|
178
|
+
|
|
179
|
+
### Versioning
|
|
180
|
+
|
|
181
|
+
This project utilizes [standard-version](https://github.com/conventional-changelog/standard-version).
|
|
182
|
+
|
|
183
|
+
- `npm run bump` - Version bumps determined automatically via commits
|
|
184
|
+
- `npm run bumpBeta` or `npm run bump -- --prerelease beta` - 4.0.x-beta.0 (if no current beta) or 4.0.0-beta.x (if current beta exists)
|
|
185
|
+
|
|
186
|
+
### Releasing
|
|
187
|
+
|
|
188
|
+
Versions should be released on npm
|
|
189
|
+
|
|
190
|
+
- `npm run release`
|
|
191
|
+
- `npm run releaseAlpha`
|
|
192
|
+
- `npm run releaseBeta`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domoinc/ryuu-proxy",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.4-beta.1",
|
|
4
4
|
"description": "a middleware that provides a proxy for local domo app development",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
"lint": "tslint src/**/*.ts --project ./tsconfig.json",
|
|
9
9
|
"test": "mocha && rm -rf test",
|
|
10
10
|
"tdd": "mocha --watch",
|
|
11
|
-
"prebuild": "npm run lint",
|
|
12
11
|
"build": "rm -rf ./dist && tsc",
|
|
13
12
|
"releaseAlpha": "npm run build && npm publish --tag alpha",
|
|
14
13
|
"releaseBeta": "npm run build && npm publish --tag beta",
|
|
15
14
|
"release": "npm run build && npm publish",
|
|
16
15
|
"start": "npm run build -- -w",
|
|
17
|
-
"clean": "rm -rf node_modules && yarn"
|
|
16
|
+
"clean": "rm -rf node_modules && yarn",
|
|
17
|
+
"bumpAlpha": "npm run build && npm run bump -- --prerelease alpha",
|
|
18
|
+
"bumpBeta": "npm run build && npm run bump -- --prerelease beta",
|
|
19
|
+
"bump": "standard-version"
|
|
18
20
|
},
|
|
19
21
|
"author": "AppTeam6 <Squad.AppTeam6@domo.com>",
|
|
20
22
|
"repository": {
|
|
@@ -42,24 +44,23 @@
|
|
|
42
44
|
"mocha": "^10.0.0",
|
|
43
45
|
"mock-req": "^0.2.0",
|
|
44
46
|
"sinon": "^14.0.0",
|
|
47
|
+
"standard-version": "^9.5.0",
|
|
45
48
|
"ts-node": "^10.9.1",
|
|
46
|
-
"tslint": "^6.1.3",
|
|
47
49
|
"tslint-config-airbnb": "^5.11.2",
|
|
48
|
-
"tslint-loader": "^3.5.4",
|
|
49
50
|
"tsutils": "^3.21.0",
|
|
50
51
|
"typescript": "^4.7.4"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
54
|
"axios": "^0.27.2",
|
|
54
55
|
"axios-cookiejar-support": "^1.0.1",
|
|
55
|
-
"busboy": "^
|
|
56
|
+
"busboy": "^1.6.0",
|
|
56
57
|
"configstore": "^5.0.1",
|
|
57
58
|
"dotenv": "^16.0.1",
|
|
58
59
|
"form-data": "^4.0.0",
|
|
59
60
|
"fs-extra": "^10.1.0",
|
|
60
61
|
"glob": "^8.0.3",
|
|
61
62
|
"https-proxy-agent": "^5.0.1",
|
|
62
|
-
"ryuu-client": "4.3.
|
|
63
|
+
"ryuu-client": "^4.3.4-beta.4",
|
|
63
64
|
"tough-cookie": "^4.0.0"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|