telos-server 1.0.19 → 1.0.21
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/package.json +1 -1
- package/telosMiddleware.js +25 -49
- package/telosRouter.js +27 -23
package/package.json
CHANGED
package/telosMiddleware.js
CHANGED
|
@@ -18,31 +18,28 @@ let extensionTypes = {
|
|
|
18
18
|
'mp4': 'video/mp4'
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
let fileTypes = [
|
|
22
|
-
'ico',
|
|
23
|
-
'png',
|
|
24
|
-
'jpg',
|
|
25
|
-
'wav',
|
|
26
|
-
'mp3',
|
|
27
|
-
'svg',
|
|
28
|
-
'pdf',
|
|
29
|
-
'doc',
|
|
30
|
-
'mp4'
|
|
31
|
-
];
|
|
32
|
-
|
|
33
21
|
let apiCache = { };
|
|
34
22
|
|
|
35
23
|
function middlewareFile(packet, file) {
|
|
36
24
|
|
|
37
|
-
if(
|
|
25
|
+
if(file.type == "folder")
|
|
38
26
|
return;
|
|
39
27
|
|
|
40
28
|
return {
|
|
41
29
|
headers: {
|
|
42
|
-
"Content-Type": extensionTypes[file.type]
|
|
30
|
+
"Content-Type": extensionTypes[file.type] != null ?
|
|
31
|
+
extensionTypes[file.type] :
|
|
32
|
+
(file.meta?.pup == null ?
|
|
33
|
+
"application/octet-stream" : "text/plain")
|
|
43
34
|
},
|
|
44
|
-
body: file.
|
|
45
|
-
|
|
35
|
+
body: file.meta?.pup == null ?
|
|
36
|
+
file.file :
|
|
37
|
+
pup.preprocess(
|
|
38
|
+
virtualSystem.getResource(
|
|
39
|
+
file.file.split(":\\").join("://").split("\\").join("/")
|
|
40
|
+
)
|
|
41
|
+
),
|
|
42
|
+
file: file.meta?.pup == null
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
|
|
@@ -107,7 +104,7 @@ function middlewareJS(packet, file) {
|
|
|
107
104
|
body: `
|
|
108
105
|
<script>
|
|
109
106
|
|
|
110
|
-
${preprocess(
|
|
107
|
+
${pup.preprocess(
|
|
111
108
|
virtualSystem.getResource(
|
|
112
109
|
file.file.
|
|
113
110
|
split(":\\").join("://").split("\\").join("/")
|
|
@@ -131,10 +128,15 @@ function middlewareJS(packet, file) {
|
|
|
131
128
|
var vision = use("kaeon-united")("vision");
|
|
132
129
|
|
|
133
130
|
vision.extend(JSON.parse("${
|
|
134
|
-
JSON.stringify(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
JSON.stringify(
|
|
132
|
+
pup.preprocess(
|
|
133
|
+
virtualSystem.getResource(
|
|
134
|
+
file.file.
|
|
135
|
+
split(":\\").join("://").
|
|
136
|
+
split("\\").join("/")
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
)
|
|
138
140
|
}");
|
|
139
141
|
|
|
140
142
|
</script>
|
|
@@ -143,37 +145,11 @@ function middlewareJS(packet, file) {
|
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
function middlewareText(packet, file) {
|
|
147
|
-
|
|
148
|
-
if(fileTypes.includes(file.type) || file.type == "folder")
|
|
149
|
-
return;
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
headers: {
|
|
153
|
-
"Content-Type": extensionTypes[file.type]
|
|
154
|
-
},
|
|
155
|
-
body: preprocess(
|
|
156
|
-
virtualSystem.getResource(
|
|
157
|
-
file.file.split(":\\").join("://").split("\\").join("/")
|
|
158
|
-
)
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function preprocess(string, file) {
|
|
164
|
-
|
|
165
|
-
return (file != null ? file.meta.pup != null : true) ?
|
|
166
|
-
pup.preprocess(string) : string;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
148
|
module.exports = {
|
|
170
149
|
extensionTypes,
|
|
171
|
-
fileTypes,
|
|
172
150
|
middleware: {
|
|
173
151
|
middlewareFile,
|
|
174
152
|
middlewareFolder,
|
|
175
|
-
middlewareJS
|
|
176
|
-
|
|
177
|
-
},
|
|
178
|
-
preprocess
|
|
153
|
+
middlewareJS
|
|
154
|
+
}
|
|
179
155
|
};
|
package/telosRouter.js
CHANGED
|
@@ -22,12 +22,13 @@ var telosRouter = {
|
|
|
22
22
|
if(packet.tags.length == 1 &&
|
|
23
23
|
(packet.tags[0] == "telos-engine" ||
|
|
24
24
|
packet.tags[0] == "telos-engine-refresh")) {
|
|
25
|
-
|
|
26
|
-
telosRouter.tasks
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
|
|
26
|
+
if(telosRouter.tasks == null ||
|
|
27
|
+
packet.tags[0] == "telos-engine-refresh") {
|
|
28
|
+
|
|
29
|
+
telosRouter.tasks = telosRouter.tasks != null ?
|
|
30
|
+
telosRouter.tasks : { };
|
|
31
|
+
|
|
31
32
|
Object.values(
|
|
32
33
|
serverUtils.getAllFiles(
|
|
33
34
|
telosRouter.config.directories
|
|
@@ -37,26 +38,29 @@ var telosRouter = {
|
|
|
37
38
|
).filter(
|
|
38
39
|
item =>
|
|
39
40
|
Object.keys(item.meta).includes("task") &&
|
|
40
|
-
item.type == "js"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
item.type == "js" &&
|
|
42
|
+
telosRouter.tasks[
|
|
43
|
+
item.file.
|
|
44
|
+
split(":\\").join("://").
|
|
45
|
+
split("\\").join("/")
|
|
46
|
+
] == null
|
|
47
|
+
).forEach(item => {
|
|
48
|
+
|
|
49
|
+
let path = item.file.
|
|
50
|
+
split(":\\").join("://").
|
|
51
|
+
split("\\").join("/");
|
|
52
|
+
|
|
53
|
+
telosRouter.tasks[path] = use(
|
|
54
|
+
virtualSystem.getResource(path),
|
|
55
|
+
{ dynamic: true }
|
|
56
|
+
)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
47
59
|
|
|
48
|
-
telosRouter.tasks.forEach(item => {
|
|
60
|
+
Object.values(telosRouter.tasks).forEach(item => {
|
|
49
61
|
|
|
50
62
|
try {
|
|
51
|
-
|
|
52
|
-
item.content = item.content != null ?
|
|
53
|
-
item.content :
|
|
54
|
-
use(
|
|
55
|
-
virtualSystem.getResource(item.path),
|
|
56
|
-
{ dynamic: true }
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
item.content();
|
|
63
|
+
item();
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
catch(error) {
|