@cocreate/file-server 1.11.0 → 1.11.2
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 +16 -0
- package/CoCreate.config.js +4 -4
- package/package.json +1 -1
- package/src/index.js +21 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## [1.11.2](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.11.1...v1.11.2) (2023-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improved handeling of header "last-modified" ([e508144](https://github.com/CoCreate-app/CoCreate-file-server/commit/e50814498fdd4cb859f06c345c8173d707fcdabd))
|
|
7
|
+
* svg bug ([db9d9f7](https://github.com/CoCreate-app/CoCreate-file-server/commit/db9d9f79ec5ee8158ad0e2f7f72862e49badc7ec))
|
|
8
|
+
|
|
9
|
+
## [1.11.1](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.11.0...v1.11.1) (2023-09-18)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* Add path and pathname ([f2ff42d](https://github.com/CoCreate-app/CoCreate-file-server/commit/f2ff42d5ecfc46807f03753c586feec1ea848148))
|
|
15
|
+
* Update dCoCreate dpendencies to latest versions ([7945630](https://github.com/CoCreate-app/CoCreate-file-server/commit/794563023c42884ddfad4a9d4c434423b67ebf32))
|
|
16
|
+
|
|
1
17
|
# [1.11.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.10.0...v1.11.0) (2023-09-17)
|
|
2
18
|
|
|
3
19
|
|
package/CoCreate.config.js
CHANGED
|
@@ -8,16 +8,16 @@ module.exports = {
|
|
|
8
8
|
"object": {
|
|
9
9
|
"_id": "60145dc49f64ba1680b86693",
|
|
10
10
|
"name": "index.html",
|
|
11
|
-
"path": "/docs/file-server
|
|
11
|
+
"path": "/docs/file-server",
|
|
12
|
+
"pathname": "/docs/file-server/index.html",
|
|
12
13
|
"src": "{{./docs/index.html}}",
|
|
13
14
|
"host": [
|
|
14
15
|
"cocreate.app",
|
|
15
16
|
"general.cocreate.app"
|
|
16
17
|
],
|
|
17
|
-
"directory": "
|
|
18
|
+
"directory": "file-server",
|
|
18
19
|
"content-type": "text/html",
|
|
19
|
-
"public": "true"
|
|
20
|
-
"website_id": "5ffbceb7f11d2d00103c4535"
|
|
20
|
+
"public": "true"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
]
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -91,14 +91,13 @@ class CoCreateFileSystem {
|
|
|
91
91
|
$filter: {
|
|
92
92
|
query: [
|
|
93
93
|
{ key: "host", value: [hostname, '*'], operator: "$in" },
|
|
94
|
-
{ key: "
|
|
94
|
+
{ key: "pathname", value: pathname, operator: "$eq" }
|
|
95
95
|
],
|
|
96
96
|
limit: 1
|
|
97
97
|
},
|
|
98
98
|
organization_id
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
102
101
|
let file
|
|
103
102
|
if (pathname.startsWith('/dist') || pathname.startsWith('/admin') || ['/403.html', '/404.html', '/offline.html', '/manifest.webmanifest', '/service-worker.js'].includes(pathname))
|
|
104
103
|
file = await getDefaultFile(pathname)
|
|
@@ -136,8 +135,18 @@ class CoCreateFileSystem {
|
|
|
136
135
|
return sendResponse(pageNotFound.object[0].src, 404, { 'Content-Type': 'text/html' })
|
|
137
136
|
}
|
|
138
137
|
|
|
138
|
+
|
|
139
|
+
if (file.modified || file.created) {
|
|
140
|
+
let modifiedOn = file.modified.on || file.created.on
|
|
141
|
+
if (modifiedOn instanceof Date)
|
|
142
|
+
modifiedOn = modifiedOn.toISOString()
|
|
143
|
+
res.setHeader('Last-Modified', modifiedOn);
|
|
144
|
+
}
|
|
145
|
+
|
|
139
146
|
let contentType = file['content-type'] || 'text/html';
|
|
140
|
-
if (contentType
|
|
147
|
+
if (contentType === 'image/svg+xml')
|
|
148
|
+
contentType = contentType
|
|
149
|
+
else if (contentType.startsWith('image/') || contentType.startsWith('audio/') || contentType.startsWith('video/')) {
|
|
141
150
|
src = src.replace(/^data:image\/(png|jpeg|jpg);base64,/, '');
|
|
142
151
|
src = Buffer.from(src, 'base64');
|
|
143
152
|
} else if (contentType === 'text/html') {
|
|
@@ -148,9 +157,6 @@ class CoCreateFileSystem {
|
|
|
148
157
|
}
|
|
149
158
|
}
|
|
150
159
|
|
|
151
|
-
if (file.modified)
|
|
152
|
-
res.setHeader('Last-Modified', file.modified.on);
|
|
153
|
-
|
|
154
160
|
sendResponse(src, 200, { 'Content-Type': contentType })
|
|
155
161
|
|
|
156
162
|
function sendResponse(src, statusCode, headers) {
|
|
@@ -176,6 +182,9 @@ class CoCreateFileSystem {
|
|
|
176
182
|
data.$filter.query[0].value = ['*']
|
|
177
183
|
data.organization_id = process.env.organization_id
|
|
178
184
|
|
|
185
|
+
if (fileName.startsWith('/admin'))
|
|
186
|
+
data.$filter.query[1].value = '/superadmin' + fileName.replace('/admin', '')
|
|
187
|
+
|
|
179
188
|
defaultFile = await crud.send(data)
|
|
180
189
|
|
|
181
190
|
if (fileName !== '/hostNotFound.html') {
|
|
@@ -193,6 +202,12 @@ class CoCreateFileSystem {
|
|
|
193
202
|
}
|
|
194
203
|
|
|
195
204
|
if (defaultFile && defaultFile.object && defaultFile.object[0] && defaultFile.object[0].src) {
|
|
205
|
+
if (fileName.startsWith('/admin')) {
|
|
206
|
+
data.object[0].directory = 'admin'
|
|
207
|
+
data.object[0].path = '/admin' + data.object[0].path.replace('/superadmin', '')
|
|
208
|
+
data.object[0].pathname = fileName
|
|
209
|
+
}
|
|
210
|
+
|
|
196
211
|
crud.send({
|
|
197
212
|
method: 'create.object',
|
|
198
213
|
array: 'files',
|