Skip to content

Commit d86b5d2

Browse files
committed
build: 3.0.3
1 parent bb0bef5 commit d86b5d2

File tree

6 files changed

+1631
-165
lines changed

6 files changed

+1631
-165
lines changed

.eslintrc.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
"indent": ["error", 2, { "SwitchCase": 1 }],
1919
"default-case": "error",
2020
"linebreak-style": ["error", "unix"],
21-
"semi": ["error", "always"]
21+
"semi": ["error", "always"],
22+
"no-console": "error",
23+
"no-undef": "error",
24+
"no-var": "error",
25+
"no-caller": "error",
26+
"no-throw-literal": "error",
27+
"no-unneeded-ternary": "error",
28+
"prefer-const": "error",
29+
"comma-spacing": ["error", { "before": false, "after": true }],
30+
"comma-style": ["error", "last"],
31+
"handle-callback-err": ["error", "^(err|error)$"]
2232
}
2333
}

.prettierignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
node_modules
2-
.all-contributorsrc
32
.eslintignore
43
.gitignore
54
.prettierignore
6-
.DS_Store
5+
.npmignore
76
LICENSE
87
*.png
98
*.txt
109
TODO
11-
*.md
10+
.DS_Store

README.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Dependency Status][david-badge]][david-badge-url]
99
<a href="#badge">
10-
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg">
10+
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg">
1111
</a>
1212

1313
# Executor for [Runnerty]: HTTP
1414

1515
### Installation:
16+
1617
Through NPM
1718

1819
```bash
@@ -34,7 +35,9 @@ rty add @runnerty/executor-http
3435
```
3536

3637
### Configuration sample:
38+
3739
Add in [config.json]:
40+
3841
```json
3942
{
4043
"id": "http_default",
@@ -43,24 +46,26 @@ Add in [config.json]:
4346
```
4447

4548
### Plan sample:
49+
4650
Add in [plan.json]:
51+
4752
```json
4853
{
4954
"id": "http_default",
50-
"headers": {"User-Agent": "runnerty"},
55+
"headers": { "User-Agent": "runnerty" },
5156
"method": "get",
5257
"url": "https://api.github.com/search/repositories",
53-
"params":{"q": "runnerty"},
58+
"params": { "q": "runnerty" },
5459
"responseType": "json"
5560
}
5661
```
5762

5863
```json
5964
{
6065
"id": "http_default",
61-
"headers": {"User-Agent": "runnerty"},
66+
"headers": { "User-Agent": "runnerty" },
6267
"url": "http://www.sample.com/form",
63-
"method":"post",
68+
"method": "post",
6469
"data": {
6570
"key1": "value1",
6671
"key2": "value2"
@@ -76,8 +81,10 @@ Add in [plan.json]:
7681
"headers": { "User-Agent": "runnerty" },
7782
"url": "http://www.sample.com/uploadfile",
7883
"method": "post",
79-
"files":[{"name":"fileOne", "path":"/var/myfile.txt"},
80-
{"name":"fileTwo", "path":"/var/www/runnerty.jpg"}],
84+
"files": [
85+
{ "name": "fileOne", "path": "/var/myfile.txt" },
86+
{ "name": "fileTwo", "path": "/var/www/runnerty.jpg" }
87+
],
8188
"responseType": "json",
8289
"returnHeaderDataOutput": true
8390
}
@@ -98,8 +105,10 @@ Add in [plan.json]:
98105
```
99106

100107
### Pagination:
108+
101109
It is possible to make calls to APIs that return `JSON` data that requires paging.
102110
The parameters available for paging are:
111+
103112
```
104113
start - page from which the query is initiated, by default 1
105114
limit - maximum elements per page
@@ -113,7 +122,9 @@ token.data_param_name - name of the parameter to be sent in the body w
113122
token.next_token_from_response - params path of the response data from which to get the next page token
114123
token.next_token_from_header - params path of the header data from which to get the next page token
115124
```
125+
116126
Some paginations examples:
127+
117128
```json
118129
{
119130
"id": "http_default",
@@ -128,6 +139,7 @@ Some paginations examples:
128139
"noReturnDataOutput": true
129140
}
130141
```
142+
131143
```json
132144
{
133145
"id": "http_default",
@@ -142,6 +154,7 @@ Some paginations examples:
142154
"noReturnDataOutput": true
143155
}
144156
```
157+
145158
```json
146159
{
147160
"id": "http_default",
@@ -161,9 +174,11 @@ Some paginations examples:
161174
```
162175

163176
### Output (Process values):
164-
* `PROCESS_EXEC_DATA_OUTPUT`: Response output data.
165-
It is possible to return the header response in dataoutput by activating the `returnHeaderDataOutput (boolean)` parameter
166-
* `EXTRA_DATA`: If the response is a `JSON` it is possible to work with the parsed values of the response using the `"responseType": "json"` parameter. If we receive for example:
177+
178+
- `PROCESS_EXEC_DATA_OUTPUT`: Response output data.
179+
It is possible to return the header response in dataoutput by activating the `returnHeaderDataOutput (boolean)` parameter
180+
- `EXTRA_DATA`: If the response is a `JSON` it is possible to work with the parsed values of the response using the `"responseType": "json"` parameter. If we receive for example:
181+
167182
```json
168183
{
169184
"planet": {
@@ -179,10 +194,11 @@ It is possible to return the header response in dataoutput by activating the `re
179194
}
180195
}
181196
```
197+
182198
It is possible to access the values by ([GETVALUE] function):
183199
`PROCESS_EXEC_PLANET_NAME`: "Mars", `PROCESS_EXEC_PLANET_NAME_SATELLITES_1_NAME`:"phobos"
184200

185-
* `PROCESS_EXEC_ERR_OUTPUT`: Error output message.
201+
- `PROCESS_EXEC_ERR_OUTPUT`: Error output message.
186202

187203
### Other considerations
188204

@@ -199,13 +215,13 @@ If the result is very large, you should consider using the "noReturnDataOutput"
199215
}
200216
```
201217

202-
[Runnerty]: http://www.runnerty.io
218+
[runnerty]: http://www.runnerty.io
203219
[downloads-image]: https://img.shields.io/npm/dm/@runnerty/executor-http.svg
204220
[npm-url]: https://www.npmjs.com/package/@runnerty/executor-http
205221
[npm-image]: https://img.shields.io/npm/v/@runnerty/executor-http.svg
206222
[david-badge]: https://david-dm.org/runnerty/executor-http.svg
207223
[david-badge-url]: https://david-dm.org/runnerty/executor-http
208-
[GETVALUE]: http://docs.runnerty.io/functions/
224+
[getvalue]: http://docs.runnerty.io/functions/
209225
[config.json]: http://docs.runnerty.io/config/
210226
[plan.json]: http://docs.runnerty.io/plan/
211-
[runnerty-cli]: https://www.npmjs.com/package/runnerty-cli
227+
[runnerty-cli]: https://www.npmjs.com/package/runnerty-cli

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class httpExecutor extends Executor {
8484
// FILES FORM
8585
if (values.files && (values.method === 'post' || values.method === 'put')) {
8686
const form = new formData();
87-
let filesLength = values.files.length;
87+
const filesLength = values.files.length;
8888
for (let i = 0; i < filesLength; i++) {
8989
form.append(values.files[i].name, fs.createReadStream(values.files[i].path));
9090
}
@@ -236,6 +236,7 @@ class httpExecutor extends Executor {
236236
resolve();
237237
})
238238
.on('error', err => {
239+
writeStream.end();
239240
throw err;
240241
});
241242
} else {
@@ -251,7 +252,6 @@ class httpExecutor extends Executor {
251252
this.endOptions.messageLog = err.message;
252253
this.endOptions.err_output = err.message;
253254
this.endOptions.end = 'error';
254-
writeStream.end();
255255
this.end(this.endOptions);
256256
resolve();
257257
}

0 commit comments

Comments
 (0)