-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
59 lines (59 loc) · 1.36 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module.exports = {
name: "api",
ns: "superagent",
description: "Super Agent is light-weight progressive ajax API",
phrases: {
active: "Creating superagent {{input.method}}: {{input.url}}"
},
ports: {
input: {
method: {
title: "Method",
type: "string",
"enum": ["GET",
"POST",
"PUT",
"HEAD",
"DELETE"
],
"default": "GET"
},
url: {
title: "URL",
type: "string",
format: "url"
},
withCredentials: {
title: "With Credentials",
description: "enables the ability to send cookies from the origin, however only when \"Access-Control-Allow-Origin\" is not a wildcard (\"*\"), and \"Access-Control-Allow-Credentials\" is \"true\"",
type: "boolean",
"default": false
}
},
output: {
request: {
type: "Request",
title: "Request"
}
}
},
dependencies: {
npm: {
superagent: require('superagent')
}
},
fn: function api(input, $, output, state, done, cb, on, superagent) {
var r = function() {
output.request = $.create(superagent($.method, $.url));
if ($.withCredentials) {
output.request.withCredentials();
}
}.call(this);
return {
output: output,
state: state,
on: on,
return: r
};
}
}