pinokiod 1.0.54 → 1.0.56
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/kernel/api/proxy/index.js +12 -0
- package/kernel/api/set/index.js +1 -0
- package/kernel/index.js +36 -0
- package/package.json +2 -2
- package/server/index.js +30 -0
|
@@ -9,7 +9,13 @@ class P {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
*/
|
|
12
|
+
ondata({
|
|
13
|
+
raw: `\r\n[Start proxy] ${req.params.name} ${req.params.uri}\r\n`
|
|
14
|
+
})
|
|
12
15
|
let response = await kernel.api.startProxy(req.parent.path, req.params.uri, req.params.name)
|
|
16
|
+
ondata({
|
|
17
|
+
raw: "Proxy Started"
|
|
18
|
+
})
|
|
13
19
|
return response
|
|
14
20
|
}
|
|
15
21
|
async stop (req, ondata, kernel) {
|
|
@@ -21,7 +27,13 @@ class P {
|
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
*/
|
|
30
|
+
ondata({
|
|
31
|
+
raw: `\r\n[Stop proxy] ${req.params.uri}\r\n`
|
|
32
|
+
})
|
|
24
33
|
kernel.api.stopProxy({ uri: req.params.uri })
|
|
34
|
+
ondata({
|
|
35
|
+
raw: "Proxy Stopped"
|
|
36
|
+
})
|
|
25
37
|
}
|
|
26
38
|
}
|
|
27
39
|
module.exports = P
|
package/kernel/api/set/index.js
CHANGED
package/kernel/index.js
CHANGED
|
@@ -39,6 +39,42 @@ class Kernel {
|
|
|
39
39
|
this.procs[uri] = undefined
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
// on(name, event) {
|
|
43
|
+
// if (name === "refresh_memory") {
|
|
44
|
+
// let urlSet = new Set()
|
|
45
|
+
// // start relevant proxies
|
|
46
|
+
// for(let scriptPath in this.memory.local) {
|
|
47
|
+
// let local = this.memory.local[scriptPath]
|
|
48
|
+
// // if 'url' is set
|
|
49
|
+
// // 1. check if a proxy is already running
|
|
50
|
+
// // 2. if running => ignore
|
|
51
|
+
// // 3. if not running => start proxy
|
|
52
|
+
// if (local.url) {
|
|
53
|
+
// urlSet.add(local.url)
|
|
54
|
+
// }
|
|
55
|
+
// let local = this.api.proxies[parentPath]
|
|
56
|
+
// }
|
|
57
|
+
//
|
|
58
|
+
// // get all running urls
|
|
59
|
+
//
|
|
60
|
+
//
|
|
61
|
+
// // stop relevant proxies
|
|
62
|
+
//
|
|
63
|
+
// for(let scriptPath in this.api.proxies) {
|
|
64
|
+
// // 1. get all the proxies for a scriptPath
|
|
65
|
+
// let proxies = this.api.proxies[scriptPath]
|
|
66
|
+
// // 2. iterate through the proxies
|
|
67
|
+
// for(let proxy of proxies) {
|
|
68
|
+
// if (urlSet.has(proxy.target)) {
|
|
69
|
+
// // the proxy target is part of the urlSet => don't do anything since all the relevant proxies have started above
|
|
70
|
+
// } else {
|
|
71
|
+
// // the proxy target is not part of the urlSet => stop the proxy
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
74
|
+
// // - if the proxy.target is included in one of the uris in one of the local variables
|
|
75
|
+
// }
|
|
76
|
+
// }
|
|
77
|
+
// }
|
|
42
78
|
local(...args) {
|
|
43
79
|
// get local variables at path
|
|
44
80
|
let v = this.memory.local[path.resolve(...args)]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.56",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"jsonpath-plus": "^7.2.0",
|
|
37
37
|
"key-store": "^1.2.0",
|
|
38
38
|
"lodash": "^4.17.21",
|
|
39
|
-
"lproxy": "^0.0.
|
|
39
|
+
"lproxy": "^0.0.2",
|
|
40
40
|
"marked": "^5.0.1",
|
|
41
41
|
"mime-types": "^2.1.35",
|
|
42
42
|
"multer": "^1.4.5-lts.1",
|
package/server/index.js
CHANGED
|
@@ -1190,6 +1190,34 @@ class Server {
|
|
|
1190
1190
|
|
|
1191
1191
|
|
|
1192
1192
|
console.log("config", JSON.stringify(config,null,2))
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
// get all proxies that belong to this repository
|
|
1196
|
+
let childProxies = []
|
|
1197
|
+
console.log("this.kernel.api.proxies=", this.kernel.api.proxies)
|
|
1198
|
+
for(let scriptPath in this.kernel.api.proxies) {
|
|
1199
|
+
let proxies = this.kernel.api.proxies[scriptPath]
|
|
1200
|
+
console.log("PROXIES", proxies)
|
|
1201
|
+
for(let proxy of proxies) {
|
|
1202
|
+
if (scriptPath.startsWith(this.kernel.path("api", name))) {
|
|
1203
|
+
childProxies.push(proxy)
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
console.log({ childProxies })
|
|
1208
|
+
|
|
1209
|
+
let proxyMenu = []
|
|
1210
|
+
for(let proxy of childProxies) {
|
|
1211
|
+
proxyMenu.push({
|
|
1212
|
+
btn: `<i class="fa-solid fa-bolt-lightning"></i> [Proxy] ${proxy.name}`,
|
|
1213
|
+
target: "_blank",
|
|
1214
|
+
href: proxy.proxy
|
|
1215
|
+
})
|
|
1216
|
+
}
|
|
1217
|
+
console.log({ proxyMenu })
|
|
1218
|
+
config.menu = proxyMenu.concat(config.menu)
|
|
1219
|
+
|
|
1220
|
+
|
|
1193
1221
|
return config
|
|
1194
1222
|
} else {
|
|
1195
1223
|
return config
|
|
@@ -1849,12 +1877,14 @@ class Server {
|
|
|
1849
1877
|
let uri = this.kernel.path("api")
|
|
1850
1878
|
await this.renderMenu(uri, name, config, [])
|
|
1851
1879
|
|
|
1880
|
+
|
|
1852
1881
|
console.log({ config })
|
|
1853
1882
|
|
|
1854
1883
|
}
|
|
1855
1884
|
|
|
1856
1885
|
|
|
1857
1886
|
|
|
1887
|
+
|
|
1858
1888
|
console.log("MEMORY", this.kernel.memory)
|
|
1859
1889
|
res.render("browser", {
|
|
1860
1890
|
running:this.kernel.api.running,
|