-
Notifications
You must be signed in to change notification settings - Fork 0
/
listen.js
61 lines (61 loc) · 1.22 KB
/
listen.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
60
61
module.exports = {
name: "listen",
ns: "http",
async: true,
description: "HTTP Listen",
phrases: {
active: "HTTP Listening on {{input.host}}:{{input.port}}"
},
ports: {
input: {
http: {
title: "Server",
type: "Server",
async: true,
required: true,
fn: function __HTTP__(data, source, state, input, $, output) {
var r = function() {
state.http = $.http.listen($.port, $.host);
output({
http: $.create(state.http)
});
}.call(this);
return {
state: state,
return: r
};
}
},
port: {
title: "Port",
type: "string",
"default": "8080"
},
host: {
title: "Host",
type: "string",
"default": "0.0.0.0"
}
},
output: {
http: {
title: "Server",
type: "Server"
}
}
},
state: {},
on: {
shutdown: function __ONSHUTDOWN__(data, source, state, input, $, output) {
var r = function() {
if (state.http) {
state.http.close();
}
}.call(this);
return {
state: state,
return: r
};
}
}
}