godprotocol 1.0.7991 → 1.1.0
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/Executables/callables.js +131 -0
- package/Executables/executables.js +230 -0
- package/Executables/functions/adminstrator/adm_register.js +29 -0
- package/Executables/functions/adminstrator/native_components.js +10 -0
- package/Executables/functions/adminstrator/query_selectors.js +10 -0
- package/Executables/functions/adminstrator/render.js +24 -0
- package/Executables/functions/array_register.js +161 -0
- package/Executables/functions/assign.js +19 -0
- package/Executables/functions/display.js +55 -0
- package/Executables/functions/folder.js +95 -0
- package/Executables/functions/folder_register.js +87 -0
- package/Executables/functions/importcheck.js +13 -0
- package/Executables/functions/indices.js +56 -0
- package/Executables/functions/len.js +22 -0
- package/Executables/functions/methods/array.js +272 -0
- package/Executables/functions/methods/string.js +197 -0
- package/Executables/functions/methods/twain.js +148 -0
- package/Executables/functions/op.js +15 -0
- package/Executables/functions/price_register.js +30 -0
- package/Executables/functions/pricing.js +26 -0
- package/Executables/functions/servers/account.js +81 -0
- package/Executables/functions/servers/account_register.js +56 -0
- package/Executables/functions/servers/block.js +21 -0
- package/Executables/functions/servers/block_register.js +18 -0
- package/Executables/functions/servers/chain.js +42 -0
- package/Executables/functions/servers/chain_register.js +28 -0
- package/Executables/functions/set_error_catch.js +34 -0
- package/Executables/functions/string_register.js +130 -0
- package/Executables/functions/twain_register.js +56 -0
- package/Executables/functions/typecast.js +43 -0
- package/Executables/functions/utils.js +9 -0
- package/Executables/stack.js +53 -0
- package/Index.js +2 -7
- package/Loader_sequence/main.js +535 -119
- package/Loader_sequence/repository.js +33 -0
- package/Objects/Account.js +220 -54
- package/Objects/Block.js +46 -16
- package/Objects/Blockweb.js +14 -0
- package/Objects/Chain.js +163 -16
- package/Objects/Fee.js +33 -0
- package/Objects/Filesystem.js +100 -26
- package/Objects/Frame.js +10 -3
- package/Objects/Manager.js +272 -46
- package/Objects/Opcodes.js +60 -10
- package/Objects/Oracle.js +90 -5
- package/Objects/Protocol.js +5 -0
- package/Objects/Virtual_machine.js +145 -53
- package/Trinity.js +20 -0
- package/callables.js +172 -0
- package/framer.js +111 -52
- package/opcodes/add.js +6 -6
- package/opcodes/indices.js +82 -0
- package/opcodes/jmp.js +12 -11
- package/opcodes/std.js +7 -2
- package/opcodes.js +72 -14
- package/package.json +6 -5
- package/readme.md +1 -1
- package/starter_scripts/constants.seq +11 -0
- package/utils/create_server.js +34 -27
- package/utils/hash.js +2 -2
- package/utils/logger.js +79 -0
- package/utils/services.js +5 -3
- package/utils/type_coersion.js +3 -0
- package/utils/vm_utils.js +292 -0
- package/.babelrc +0 -3
- package/build/Account.js +0 -162
- package/build/Block.js +0 -65
- package/build/Blockweb.js +0 -36
- package/build/Chain.js +0 -119
- package/build/Explorer.js +0 -47
- package/build/Filesystem.js +0 -127
- package/build/Frame.js +0 -52
- package/build/Index.js +0 -15
- package/build/Manager.js +0 -99
- package/build/Opcodes.js +0 -39
- package/build/Oracle.js +0 -42
- package/build/Virtual_machine.js +0 -128
- package/build/add.js +0 -41
- package/build/create_server.js +0 -119
- package/build/framer.js +0 -57
- package/build/functions.js +0 -82
- package/build/hash.js +0 -14
- package/build/jmp.js +0 -19
- package/build/main.js +0 -283
- package/build/opcodes.js +0 -42
- package/build/privacy.js +0 -27
- package/build/services.js +0 -50
- package/build/std.js +0 -11
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const getter = (args) => {
|
|
2
|
+
let base = args.op0;
|
|
3
|
+
|
|
4
|
+
// console.log(args, 'getter.args')
|
|
5
|
+
if(!base)return base === ''?null: base
|
|
6
|
+
|
|
7
|
+
if (typeof base === "number") return base;
|
|
8
|
+
|
|
9
|
+
if (typeof base === "string") return base[args.op1];
|
|
10
|
+
|
|
11
|
+
if (Array.isArray(base)) return base.slice(args.op1)[0];
|
|
12
|
+
|
|
13
|
+
return base[args.op1];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const setter = (args, vm) => {
|
|
17
|
+
let base = args.op0;
|
|
18
|
+
|
|
19
|
+
if (typeof base === "number") return base;
|
|
20
|
+
|
|
21
|
+
if(vm.is_readonly(args))return;
|
|
22
|
+
|
|
23
|
+
if (typeof base === "string") {
|
|
24
|
+
if (args.op1 ===0 && base.length <= 1){
|
|
25
|
+
base = `${args.op2}${base}`
|
|
26
|
+
} else if (args.op1 ===-1){
|
|
27
|
+
base = `${base}${args.op2}`
|
|
28
|
+
} else base = `${base.slice(0, args.op1)}${args.op2}${base.slice(args.op1)}`;
|
|
29
|
+
} else {
|
|
30
|
+
if (Array.isArray(base)) {
|
|
31
|
+
if (args.op1<0|| args.op1 == null || args.op1 >= base.length) base.push(args.op2);
|
|
32
|
+
else base[args.op1] = args.op2;
|
|
33
|
+
} else base[args.op1] = args.op2;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return base;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const del = (args, vm)=>{
|
|
40
|
+
let base = args.op0
|
|
41
|
+
|
|
42
|
+
if (typeof base === 'number')return;
|
|
43
|
+
|
|
44
|
+
if(vm.is_readonly(args))return;
|
|
45
|
+
|
|
46
|
+
if (typeof base === 'string'){
|
|
47
|
+
if (args.op1 === 0){
|
|
48
|
+
base = base.slice(1)
|
|
49
|
+
}else if (args === -1){
|
|
50
|
+
base = base.slice(0, -1)
|
|
51
|
+
}else {
|
|
52
|
+
base = `${base.slice(0, args.op1)}${base.slice(args.op1+1)}`
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (Array.isArray(base)){
|
|
57
|
+
base.splice(args.op1, 1)
|
|
58
|
+
}else delete base[args.op1]
|
|
59
|
+
}
|
|
60
|
+
return base;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const slice = (args, vm)=>{
|
|
64
|
+
let obj = args.op0
|
|
65
|
+
let indexes = args.op1
|
|
66
|
+
if (!Array.isArray(indexes))return vm.stderr(`Indexes must be an array`)
|
|
67
|
+
|
|
68
|
+
let res;
|
|
69
|
+
|
|
70
|
+
if (typeof obj === 'number' ||!obj)return null;
|
|
71
|
+
|
|
72
|
+
if (typeof obj === 'object' && !Array.isArray(obj)){
|
|
73
|
+
res = {}
|
|
74
|
+
indexes.map(i=>{
|
|
75
|
+
res[i] = obj[i]
|
|
76
|
+
})
|
|
77
|
+
}else res = obj.slice(indexes[0], indexes[1])
|
|
78
|
+
|
|
79
|
+
return res;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { setter, getter , del, slice};
|
package/opcodes/jmp.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
const jmp = (args, vm) => {
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
const jmp = (args, vm, meta) => {
|
|
2
|
+
meta = meta || {};
|
|
3
|
+
let { flag, inverse } = meta;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
let condition;
|
|
6
|
+
if (flag) condition = vm.flags[flag];
|
|
7
|
+
if (inverse) condition = !!!condition;
|
|
8
|
+
|
|
9
|
+
if ((condition || !flag) && typeof args.op0 === "number") {
|
|
10
|
+
vm.track.pointer = args.op0;
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
track.hold = args.hold;
|
|
12
|
+
vm.pop_context()
|
|
13
|
+
}
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
export { jmp
|
|
16
|
+
export { jmp };
|
package/opcodes/std.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
const stdout = (args) => {
|
|
1
|
+
const stdout = (args, vm) => {
|
|
2
2
|
if (!args) return;
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
args&& args.op0&& vm.account.stdout.push({ data: args, pid: vm.track.pid });
|
|
5
|
+
|
|
6
|
+
let logs = []
|
|
7
|
+
for (let v in args) logs.push(args[v].static_value == null ? null :args[v].static_value);
|
|
8
|
+
|
|
9
|
+
console.log(...logs)
|
|
5
10
|
};
|
|
6
11
|
|
|
7
12
|
export { stdout };
|
package/opcodes.js
CHANGED
|
@@ -1,37 +1,95 @@
|
|
|
1
1
|
// import { socket_send } from "./Socket";
|
|
2
|
+
import callables from "./callables";
|
|
2
3
|
import { ops } from "./opcodes/add";
|
|
3
|
-
import {
|
|
4
|
+
import { del, getter, setter, slice } from "./opcodes/indices";
|
|
5
|
+
import { jmp } from "./opcodes/jmp";
|
|
4
6
|
import { stdout } from "./opcodes/std";
|
|
5
7
|
import { post_request } from "./utils/services";
|
|
6
8
|
|
|
7
9
|
const opcodes = (account) => {
|
|
10
|
+
callables(account)
|
|
11
|
+
|
|
8
12
|
let set = account.vm.set;
|
|
9
13
|
|
|
10
14
|
ops.map((op) => {
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
if(op.jmp){
|
|
16
|
+
let flag = op.name
|
|
17
|
+
account.vm.flags[flag] = false
|
|
18
|
+
|
|
19
|
+
set(`jmp_${flag}`, (args, vm) => jmp(args, vm, { flag }));
|
|
20
|
+
set(`jmp_not_${flag}`, (args, vm) =>
|
|
21
|
+
jmp(args, vm, { flag, inverse: true })
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set(op.name, (args) => {
|
|
26
|
+
if (!args) return;
|
|
27
|
+
try {
|
|
28
|
+
let {op0, op1}=args;
|
|
29
|
+
|
|
30
|
+
let type0 = op0.type
|
|
31
|
+
let type1 = op1.type
|
|
32
|
+
|
|
33
|
+
let val0 = op0.static_value;
|
|
34
|
+
let val1 = op1.static_value;
|
|
35
|
+
|
|
36
|
+
if(op.name ==='divide' && val1 === 0){
|
|
37
|
+
return account.vm.stderr({name:'Zero_division_error', message: 'Do not divide by zero'})
|
|
38
|
+
}
|
|
13
39
|
|
|
14
|
-
|
|
15
|
-
let result = eval(`${args.op0} ${op.sign} ${args.op1}`);
|
|
40
|
+
let result = eval(`val0 ${op.sign} val1`);
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
if (op.jmp) {
|
|
43
|
+
result = !!result;
|
|
44
|
+
account.vm.flags[op.name] = result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.log("opcodes: ", e.message);
|
|
50
|
+
console.log(e)
|
|
51
|
+
}
|
|
52
|
+
});
|
|
22
53
|
});
|
|
23
54
|
|
|
24
|
-
|
|
55
|
+
Object.keys(account.vm.flags).map((flag) => {
|
|
56
|
+
set(`jmp_${flag}`, (args, vm) => jmp(args, vm, { flag }));
|
|
57
|
+
set(`jmp_not_${flag}`, (args, vm) =>
|
|
58
|
+
jmp(args, vm, { flag, inverse: true })
|
|
59
|
+
);
|
|
60
|
+
});
|
|
25
61
|
set("jmp", jmp);
|
|
26
|
-
|
|
62
|
+
|
|
63
|
+
// Indices
|
|
64
|
+
set("setter", setter);
|
|
65
|
+
set("getter", getter);
|
|
66
|
+
set("del", del);
|
|
67
|
+
set("slice", slice);
|
|
27
68
|
|
|
28
69
|
set("send", (data) => post_request(data, account.vm.stdin));
|
|
29
70
|
// set("socket_send", socket_send);
|
|
30
71
|
|
|
31
72
|
set("stdout", stdout);
|
|
73
|
+
set("stdin",args=>account. vm.stdin(args&&args.op0));
|
|
74
|
+
|
|
75
|
+
/* Aliases */
|
|
76
|
+
set('quit', account.vm.quit)
|
|
77
|
+
set('exit', account.vm.quit)
|
|
78
|
+
|
|
79
|
+
set('ret', arg=>account.vm.quit(arg, 'ret'))
|
|
80
|
+
|
|
81
|
+
set('exec', account.vm.exec)
|
|
82
|
+
|
|
83
|
+
set('config', account.vm.set_config)
|
|
84
|
+
|
|
85
|
+
set("add_server", (args) => account.add_server(args && args.op0));
|
|
86
|
+
|
|
87
|
+
["run", "load", "parse"].map((op) =>
|
|
88
|
+
set(op, (arg) => arg && arg.op0 && account.manager.endpoint(op, arg && arg.op0))
|
|
89
|
+
);
|
|
32
90
|
|
|
33
|
-
|
|
34
|
-
|
|
91
|
+
set("add_account", (arg) =>
|
|
92
|
+
account. manager.add_account({ ...arg.op0, string: true })
|
|
35
93
|
);
|
|
36
94
|
};
|
|
37
95
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "godprotocol",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A data mediator.",
|
|
5
5
|
"main": "Index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/
|
|
25
|
+
"url": "git+https://github.com/godprotocol4/godprotocol.git"
|
|
26
26
|
},
|
|
27
27
|
"bugs": {
|
|
28
|
-
"url": "https://github.com/
|
|
28
|
+
"url": "https://github.com/godprotocol4/godprotocol/issues"
|
|
29
29
|
},
|
|
30
|
-
"homepage": "https://github.com/
|
|
30
|
+
"homepage": "https://github.com/godprotocol4/godprotocol#readme",
|
|
31
31
|
"keywords": [
|
|
32
32
|
"web 4.0",
|
|
33
33
|
"framework",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"crypto": "^1.0.1",
|
|
47
47
|
"elliptic": "^6.5.5",
|
|
48
|
-
"fs": "^0.0.1-security"
|
|
48
|
+
"fs": "^0.0.1-security",
|
|
49
|
+
"generalised-datastore": "^2.0.112"
|
|
49
50
|
},
|
|
50
51
|
"publishConfig": {
|
|
51
52
|
"ignore": [
|
package/readme.md
CHANGED
|
@@ -116,7 +116,7 @@ Type `method`
|
|
|
116
116
|
| | string | `account` | Account instance to execute the instructions in. |
|
|
117
117
|
| `cb` | function | | A function that is called with the blocks mined during the execution. |
|
|
118
118
|
|
|
119
|
-
See the [package source](https://github.com/
|
|
119
|
+
See the [package source](https://github.com/godprotocol4/GodProtocol) for more details.
|
|
120
120
|
|
|
121
121
|
[npm-url]: https://npmjs.org/package/godprotocol
|
|
122
122
|
[downloads-url]: https://npmjs.org/package/godprotocol
|
package/utils/create_server.js
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
import http from "http";
|
|
2
2
|
import { is_port_available } from "./functions";
|
|
3
|
-
import { initiator } from "../Index";
|
|
4
3
|
|
|
5
4
|
let PORT = Number(process.env.PORT) || 1408;
|
|
6
5
|
|
|
7
6
|
const cb = (res, data) => {
|
|
8
7
|
if (typeof data !== "string") data = JSON.stringify(data);
|
|
9
8
|
|
|
10
|
-
res(data);
|
|
9
|
+
res.end(data);
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
let extensions = new Object();
|
|
14
13
|
|
|
15
14
|
const extension = (route, handler) => {
|
|
16
|
-
|
|
17
|
-
if (!handlers) {
|
|
18
|
-
handlers = new Array();
|
|
19
|
-
extensions[route] = handlers;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
handlers.push(handler);
|
|
15
|
+
extensions[route] = handler;
|
|
23
16
|
};
|
|
24
17
|
|
|
25
|
-
const handle_routes = (req, res, app) => {
|
|
18
|
+
const handle_routes = (req, res, app, manager) => {
|
|
26
19
|
let data = "";
|
|
27
20
|
|
|
28
21
|
let is_in_default_routes = [
|
|
@@ -38,34 +31,45 @@ const handle_routes = (req, res, app) => {
|
|
|
38
31
|
});
|
|
39
32
|
|
|
40
33
|
req.on("end", () => {
|
|
34
|
+
if (req.method === 'GET'){
|
|
35
|
+
console.log(req.url)
|
|
36
|
+
if(req.url === '/' ){
|
|
37
|
+
res.writeHead(404, { "Content-Type": "text/html" });
|
|
38
|
+
res.end(`<h1>God Protocol</h1>`);
|
|
39
|
+
}
|
|
40
|
+
else if(req.url.startsWith('/Accounts') ){
|
|
41
|
+
manager.handle_route({req, res});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
41
46
|
try {
|
|
42
47
|
data = JSON.parse(data);
|
|
43
48
|
} catch (e) {
|
|
44
|
-
return cb(res
|
|
49
|
+
return cb(res, {
|
|
50
|
+
error_message: "Invalid data",
|
|
51
|
+
url: req.url,
|
|
52
|
+
error: true,
|
|
53
|
+
});
|
|
45
54
|
}
|
|
46
55
|
|
|
56
|
+
|
|
47
57
|
if (req.url === "/create_account") {
|
|
48
|
-
let account =
|
|
49
|
-
|
|
58
|
+
let account = manager.add_account(null, { ...data, string: true });
|
|
59
|
+
|
|
60
|
+
res.end(account);
|
|
50
61
|
} else if (["run", "load", "parse"].includes(req.url.slice(1))) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
initiator.endpoint(req.url.slice(1), payload);
|
|
62
|
+
manager.endpoint(req.url.slice(1), payload, (datagram) =>
|
|
63
|
+
cb(res, datagram)
|
|
64
|
+
);
|
|
56
65
|
} else {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
extension &&
|
|
60
|
-
extension.map((ex) => {
|
|
61
|
-
typeof ex === "function" && ex(data, { req, res });
|
|
62
|
-
});
|
|
66
|
+
manager.handle_route({req,res, data})
|
|
63
67
|
}
|
|
64
68
|
});
|
|
65
69
|
|
|
66
70
|
req.on("error", (e) => {
|
|
67
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
68
|
-
res.end(JSON.stringify({ status: "error",
|
|
71
|
+
// res.writeHead(500, { "Content-Type": "application/json" });
|
|
72
|
+
res.end(JSON.stringify({ status: "error", error_message: e.message }));
|
|
69
73
|
});
|
|
70
74
|
} else {
|
|
71
75
|
app && app(req, res);
|
|
@@ -88,10 +92,13 @@ const create_server = async (app, settings) => {
|
|
|
88
92
|
}
|
|
89
93
|
PORT = port;
|
|
90
94
|
|
|
91
|
-
let server = http.createServer((req, res) =>
|
|
95
|
+
let server = http.createServer((req, res) =>
|
|
96
|
+
handle_routes(req, res, app, settings.manager)
|
|
97
|
+
);
|
|
92
98
|
|
|
93
99
|
server.listen(port, () => {
|
|
94
100
|
console.log(`\n...GOD PROTOCOL RUNNING :${port}`);
|
|
101
|
+
settings.manager.add_server({ ...settings.server_details, port: PORT });
|
|
95
102
|
});
|
|
96
103
|
};
|
|
97
104
|
|
package/utils/hash.js
CHANGED
package/utils/logger.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const blessed = require('blessed');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// const screen = blessed.screen({
|
|
5
|
+
// smartCSR: true,
|
|
6
|
+
// title:'God Protocol'
|
|
7
|
+
// })
|
|
8
|
+
|
|
9
|
+
class Logger {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.log_boxes= new Array()
|
|
12
|
+
|
|
13
|
+
// this. clock_box = blessed.box({
|
|
14
|
+
// left: 'left',
|
|
15
|
+
// width: '100%',
|
|
16
|
+
// height: 'shrink',
|
|
17
|
+
// content: '',
|
|
18
|
+
// tags: true,
|
|
19
|
+
// border: {
|
|
20
|
+
// type: 'line'
|
|
21
|
+
// },
|
|
22
|
+
// style: {
|
|
23
|
+
// border: {
|
|
24
|
+
// fg: 'cyan'
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
// })
|
|
28
|
+
|
|
29
|
+
// screen.append(this.clock_box)
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
log=(data_logger)=> {
|
|
36
|
+
// this.clock_box.setContent(data_logger())
|
|
37
|
+
// this.update_log_box_positions()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
update_log_box_positions() {
|
|
42
|
+
// this.log_boxes.forEach((box, index) => {
|
|
43
|
+
// box.top = index;
|
|
44
|
+
// });
|
|
45
|
+
|
|
46
|
+
// this.clock_box.top = this.log_boxes.length;
|
|
47
|
+
// screen.render();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
store_log=(message)=> {
|
|
51
|
+
// const logBox = blessed.box({
|
|
52
|
+
// top: this.log_boxes.length,
|
|
53
|
+
// left: 'left',
|
|
54
|
+
// width: '100%',
|
|
55
|
+
// height: 3,
|
|
56
|
+
// content: message,
|
|
57
|
+
// tags: true,
|
|
58
|
+
// border: {
|
|
59
|
+
// type: 'line'
|
|
60
|
+
// },
|
|
61
|
+
// style: {
|
|
62
|
+
// border: {
|
|
63
|
+
// fg: 'green'
|
|
64
|
+
// }
|
|
65
|
+
// }
|
|
66
|
+
// });
|
|
67
|
+
|
|
68
|
+
// screen.append(logBox);
|
|
69
|
+
// this.log_boxes.push(logBox);
|
|
70
|
+
// this. update_log_box_positions();
|
|
71
|
+
// screen.render();
|
|
72
|
+
// console.log(message)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export default Logger;
|
package/utils/services.js
CHANGED
|
@@ -12,13 +12,15 @@ const post_request = (payload, cb) => {
|
|
|
12
12
|
// },
|
|
13
13
|
// };
|
|
14
14
|
|
|
15
|
+
let data = typeof payload.data !== 'string' ? JSON.stringify(payload.data) : payload.data
|
|
16
|
+
|
|
15
17
|
let req = http.request(
|
|
16
18
|
{
|
|
17
19
|
...payload.options,
|
|
18
20
|
method: "POST",
|
|
19
21
|
headers: {
|
|
20
22
|
"Content-Type": "application/json",
|
|
21
|
-
"Content-Length": Buffer.byteLength(
|
|
23
|
+
"Content-Length": Buffer.byteLength(data),
|
|
22
24
|
},
|
|
23
25
|
},
|
|
24
26
|
(res) => {
|
|
@@ -37,11 +39,11 @@ const post_request = (payload, cb) => {
|
|
|
37
39
|
);
|
|
38
40
|
|
|
39
41
|
req.on("error", (e) => {
|
|
40
|
-
cb(e.message);
|
|
42
|
+
cb && cb(e.message);
|
|
41
43
|
console.error(`Problem with request: ${e.message}`);
|
|
42
44
|
});
|
|
43
45
|
|
|
44
|
-
req.write(
|
|
46
|
+
req.write(data);
|
|
45
47
|
|
|
46
48
|
req.end();
|
|
47
49
|
};
|