@bee.js/node 0.0.63 → 0.0.65
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/lib/beeHive/start.js +37 -30
- package/package.json +1 -1
- package/tools/guid.js +10 -4
package/lib/beeHive/start.js
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
const log
|
|
2
|
-
const beeDEV
|
|
3
|
-
const https
|
|
4
|
-
const fs
|
|
5
|
-
|
|
6
|
-
module.exports = function(app) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
1
|
+
const log = require("./log");
|
|
2
|
+
const beeDEV = require("../DEV/beeDEV");
|
|
3
|
+
const https = require("https");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
|
|
6
|
+
module.exports = function (app) {
|
|
7
|
+
const ports = (global.configs.port || global.configs.ports || 1987.443)
|
|
8
|
+
.toString()
|
|
9
|
+
.split(".");
|
|
10
|
+
|
|
11
|
+
app.post("/beedev/:action", beeDEV); //TODO check security and create a method for define enable/disable
|
|
12
|
+
|
|
13
|
+
app.listen(ports[0]);
|
|
14
|
+
|
|
15
|
+
log(`${configs.name || "Bee.js"} started.`);
|
|
16
|
+
log(`${configs.name || "System"} listening at http://localhost:${ports[0]}`);
|
|
17
|
+
|
|
18
|
+
if (ports.length === 1) return;
|
|
19
|
+
|
|
20
|
+
const certificate = fs.existsSync(
|
|
21
|
+
require.main.path + "/server/certificate/cert.pem"
|
|
22
|
+
)
|
|
23
|
+
? {
|
|
24
|
+
key: fs.readFileSync(require.main.path + "/server/certificate/key.pem"),
|
|
25
|
+
cert: fs.readFileSync(
|
|
26
|
+
require.main.path + "/server/certificate/cert.pem"
|
|
27
|
+
),
|
|
28
|
+
passphrase: "beejs.org",
|
|
29
|
+
}
|
|
30
|
+
: {};
|
|
31
|
+
|
|
32
|
+
const server = https.createServer(certificate, app).listen(ports[1]);
|
|
33
|
+
|
|
34
|
+
log(`${configs.name || "Bee.js"} listening at https://localhost:${ports[1]}`);
|
|
35
|
+
|
|
36
|
+
return server;
|
|
37
|
+
};
|
package/package.json
CHANGED
package/tools/guid.js
CHANGED
|
@@ -7,9 +7,15 @@ module.exports = {
|
|
|
7
7
|
return fn ? uuid[fn](param) : uuid.v4();
|
|
8
8
|
},
|
|
9
9
|
|
|
10
|
-
guidToBin: function (param) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
guidToBin: function guiToBin(param) {
|
|
11
|
+
if (typeof param !== "string") return null;
|
|
12
|
+
|
|
13
|
+
const uuidRegex =
|
|
14
|
+
/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
15
|
+
if (!uuidRegex.test(param)) return null;
|
|
16
|
+
|
|
17
|
+
return "0x" + param.replace(/-/g, "");
|
|
14
18
|
},
|
|
19
|
+
|
|
20
|
+
uuidToBin: this.guidToBin,
|
|
15
21
|
};
|