@cocreate/file-server 1.15.2 → 1.16.0
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/package.json +1 -1
- package/src/index.js +25 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [1.16.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.15.2...v1.16.0) (2024-01-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* applied host to define environment/branch ([e3ad9e0](https://github.com/CoCreate-app/CoCreate-file-server/commit/e3ad9e0f38aafa3710d3ae49957ebe714b765e22))
|
|
7
|
+
* convert storage to boolean ([280a178](https://github.com/CoCreate-app/CoCreate-file-server/commit/280a178da956cb943e41d13854e330709ed2b1eb))
|
|
8
|
+
* removed host.files as handled from crud-server ([5418c06](https://github.com/CoCreate-app/CoCreate-file-server/commit/5418c06cc00985115045bcfbfc03d56cafaf3a09))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* bumped CoCreate dependencies to their latest versions ([5ad1994](https://github.com/CoCreate-app/CoCreate-file-server/commit/5ad199440e9023fa25301c7eef98f033c5832e66))
|
|
14
|
+
* query wildcard pathname ([bdd4e99](https://github.com/CoCreate-app/CoCreate-file-server/commit/bdd4e998bd986469dad99d6976c2fc9288ddef1d))
|
|
15
|
+
* routing logic per host ([7964778](https://github.com/CoCreate-app/CoCreate-file-server/commit/7964778ce6ee231c39ea6ce7721e6ec5da3ad107))
|
|
16
|
+
|
|
1
17
|
## [1.15.2](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.15.1...v1.15.2) (2023-12-31)
|
|
2
18
|
|
|
3
19
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -27,11 +27,16 @@ class CoCreateFileSystem {
|
|
|
27
27
|
|
|
28
28
|
async send(req, res, crud, organization, valideUrl) {
|
|
29
29
|
try {
|
|
30
|
+
if (!organization) {
|
|
31
|
+
let hostNotFound = await getDefaultFile('/hostNotFound.html')
|
|
32
|
+
return sendResponse(hostNotFound.object[0].src, 404, { 'Content-Type': 'text/html' })
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
const organization_id = organization._id
|
|
31
36
|
const hostname = valideUrl.hostname;
|
|
32
37
|
|
|
33
38
|
res.setHeader('organization', organization_id)
|
|
34
|
-
res.setHeader('storage', organization.storage);
|
|
39
|
+
res.setHeader('storage', !!organization.storage);
|
|
35
40
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
36
41
|
res.setHeader('Access-Control-Allow-Methods', '');
|
|
37
42
|
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
@@ -56,13 +61,29 @@ class CoCreateFileSystem {
|
|
|
56
61
|
return sendResponse(balanceFalse.object[0].src, 403, { 'Content-Type': 'text/html', 'Account-Balance': 'false', 'storage': organization.storage })
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
let lastIndex = pathname.lastIndexOf('/');
|
|
65
|
+
let wildcardPath = pathname.substring(0, lastIndex + 1);
|
|
66
|
+
let wildcard = pathname.substring(lastIndex + 1);
|
|
67
|
+
|
|
68
|
+
if (wildcard.includes('.')) {
|
|
69
|
+
let fileLastIndex = wildcard.lastIndexOf('.');
|
|
70
|
+
let fileExtension = wildcard.substring(fileLastIndex); // Get extension
|
|
71
|
+
wildcard = wildcardPath + '*' + fileExtension; // Create wildcard for file name
|
|
72
|
+
} else {
|
|
73
|
+
wildcard = wildcardPath + '*'; // Append '*' if it's just a path or folder
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// console.log("Wildcard: ", wildcard);
|
|
77
|
+
|
|
59
78
|
let data = {
|
|
60
79
|
method: 'object.read',
|
|
80
|
+
host: hostname,
|
|
61
81
|
array: 'files',
|
|
62
82
|
$filter: {
|
|
63
83
|
query: [
|
|
64
84
|
{ key: "host", value: [hostname, '*'], operator: "$in" },
|
|
65
|
-
{ key: "pathname", value: pathname, operator: "$
|
|
85
|
+
{ key: "pathname", value: pathname, operator: "$or" },
|
|
86
|
+
{ key: "pathname", value: wildcard, operator: "$or" }
|
|
66
87
|
],
|
|
67
88
|
limit: 1
|
|
68
89
|
},
|
|
@@ -92,6 +113,7 @@ class CoCreateFileSystem {
|
|
|
92
113
|
else {
|
|
93
114
|
let fileSrc = await crud.send({
|
|
94
115
|
method: 'object.read',
|
|
116
|
+
host: hostname,
|
|
95
117
|
array: file['array'],
|
|
96
118
|
object: {
|
|
97
119
|
_id: file._id
|
|
@@ -180,6 +202,7 @@ class CoCreateFileSystem {
|
|
|
180
202
|
|
|
181
203
|
crud.send({
|
|
182
204
|
method: 'object.create',
|
|
205
|
+
host: hostname,
|
|
183
206
|
array: 'files',
|
|
184
207
|
object: defaultFile.object[0],
|
|
185
208
|
organization_id
|