@cocreate/file-server 1.0.13 → 1.0.15
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/index.js +16 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.0.15](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.14...v1.0.15) (2022-12-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* console.logs ([e73293f](https://github.com/CoCreate-app/CoCreate-file-server/commit/e73293fbb50330760a42250b773581527e870bd3))
|
|
7
|
+
|
|
8
|
+
## [1.0.14](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.13...v1.0.14) (2022-12-05)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* typo res.end ([2299a83](https://github.com/CoCreate-app/CoCreate-file-server/commit/2299a83a7f54b14a6f034cfa54563f090acfc344))
|
|
14
|
+
|
|
1
15
|
## [1.0.13](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.12...v1.0.13) (2022-12-05)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -87,38 +87,31 @@ class CoCreateFileSystem {
|
|
|
87
87
|
res.send('could not find src');
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
let
|
|
90
|
+
let contentType = file['content-type'] || mime.lookup(url) || 'text/html';
|
|
91
91
|
|
|
92
|
-
if (
|
|
92
|
+
if (contentType.startsWith('image/') || contentType.startsWith('audio/') || contentType.startsWith('video/')) {
|
|
93
93
|
var base64Data = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
|
|
94
94
|
let file = Buffer.from(base64Data, 'base64');
|
|
95
95
|
res.writeHead(200, {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
'Content-Type': contentType,
|
|
97
|
+
'Content-Length': file.length
|
|
98
98
|
});
|
|
99
|
-
res.
|
|
100
|
-
}
|
|
101
|
-
else if (content_type === 'text/html') {
|
|
99
|
+
res.send(file);
|
|
100
|
+
} else if (contentType === 'text/html') {
|
|
102
101
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
console.log('html src', src)
|
|
103
|
+
let html = await render.HTML(src, organization_id);
|
|
104
|
+
console.log('returned html', html)
|
|
105
|
+
if (html)
|
|
106
|
+
src = html
|
|
106
107
|
}
|
|
107
108
|
catch (err) {
|
|
108
|
-
|
|
109
|
-
console.log('infinte loop')
|
|
110
|
-
return res.send('there is a infinite loop');
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
console.warn('server-render: ' + err.message)
|
|
115
|
-
return res.send(src + `<script>console.log("${'server-render: ' + err.message}")</script>`)
|
|
116
|
-
}
|
|
109
|
+
console.warn('server-render: ' + err.message)
|
|
117
110
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
else {
|
|
121
|
-
res.type(
|
|
111
|
+
res.type(contentType);
|
|
112
|
+
res.send(src)
|
|
113
|
+
} else {
|
|
114
|
+
res.type(contentType);
|
|
122
115
|
res.send(src);
|
|
123
116
|
}
|
|
124
117
|
|