@cocreate/file-server 1.16.11 → 1.17.1
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 +13 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.17.1](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.17.0...v1.17.1) (2024-11-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handing condition if organization id not found ([d0a956d](https://github.com/CoCreate-app/CoCreate-file-server/commit/d0a956d2e1f88c5c836a346972dff72fc28f2b97))
|
|
7
|
+
|
|
8
|
+
# [1.17.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.16.11...v1.17.0) (2024-09-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* serve xml files and replaceAll {${host}} placeholders with requesting host ([7bda848](https://github.com/CoCreate-app/CoCreate-file-server/commit/7bda84882688c504e04c63e6f44546815754fe86))
|
|
14
|
+
|
|
1
15
|
## [1.16.11](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.16.10...v1.16.11) (2024-08-30)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -42,12 +42,13 @@ class CoCreateFileSystem {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
let organization_id
|
|
45
46
|
if (!organization || organization.error) {
|
|
46
47
|
let hostNotFound = await getDefaultFile('/hostNotFound.html')
|
|
47
48
|
return sendResponse(hostNotFound.object[0].src, 404, { 'Content-Type': 'text/html' })
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
organization_id = organization._id
|
|
51
52
|
data.organization_id = organization_id
|
|
52
53
|
|
|
53
54
|
res.setHeader('organization', organization_id)
|
|
@@ -145,7 +146,7 @@ class CoCreateFileSystem {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
let contentType = file['content-type'] || 'text/html';
|
|
148
|
-
|
|
149
|
+
|
|
149
150
|
if (/^data:image\/[a-zA-Z0-9+.-]+;base64,([A-Za-z0-9+/]+={0,2})$/.test(src)) {
|
|
150
151
|
src = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
|
|
151
152
|
src = Buffer.from(src, 'base64');
|
|
@@ -155,8 +156,11 @@ class CoCreateFileSystem {
|
|
|
155
156
|
try {
|
|
156
157
|
src = await this.render.HTML(src, organization_id);
|
|
157
158
|
} catch (err) {
|
|
158
|
-
console.warn('server-render: ' + err.message)
|
|
159
|
+
console.warn('server-side-render: ' + err.message)
|
|
159
160
|
}
|
|
161
|
+
} else if (contentType === 'text/xml' || contentType === 'application/xml') {
|
|
162
|
+
const protocol = 'https://' // || req.headers['x-forwarded-proto'] || req.protocol;
|
|
163
|
+
src = src.replaceAll('{{$host}}', `${protocol}${hostname}`)
|
|
160
164
|
}
|
|
161
165
|
|
|
162
166
|
sendResponse(src, 200, { 'Content-Type': contentType })
|
|
@@ -173,11 +177,12 @@ class CoCreateFileSystem {
|
|
|
173
177
|
src = JSON.stringify(src);
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
if (organization_id)
|
|
181
|
+
crud.wsManager.emit("setBandwidth", {
|
|
182
|
+
type: 'out',
|
|
183
|
+
data: src,
|
|
184
|
+
organization_id
|
|
185
|
+
});
|
|
181
186
|
res.writeHead(statusCode, headers);
|
|
182
187
|
return res.end(src);
|
|
183
188
|
} catch (error) {
|