@cocreate/file-server 1.2.0 → 1.2.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 +7 -0
- package/package.json +1 -1
- package/src/index.js +22 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.2.1](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.2.0...v1.2.1) (2023-05-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handeling of superadmin signup ([06a5b96](https://github.com/CoCreate-app/CoCreate-file-server/commit/06a5b963bd8f552d02baa3ac9f749071a8387653))
|
|
7
|
+
|
|
1
8
|
# [1.2.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.1.3...v1.2.0) (2023-05-05)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -27,7 +27,7 @@ class CoCreateFileSystem {
|
|
|
27
27
|
return file.document[0].src
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
let default403, default404, hostNotFound
|
|
30
|
+
let default403, default404, hostNotFound, signup
|
|
31
31
|
defaultFiles('/403.html').then((file) => {
|
|
32
32
|
default403 = file
|
|
33
33
|
})
|
|
@@ -37,12 +37,15 @@ class CoCreateFileSystem {
|
|
|
37
37
|
defaultFiles('/hostNotFound.html').then((file) => {
|
|
38
38
|
hostNotFound = file
|
|
39
39
|
})
|
|
40
|
+
defaultFiles('/superadmin/signup.html').then((file) => {
|
|
41
|
+
signup = file
|
|
42
|
+
})
|
|
40
43
|
|
|
41
44
|
this.router = router.get('/*', async(req, res) => {
|
|
42
45
|
let hostname = req.hostname;
|
|
43
|
-
let
|
|
44
|
-
if (!
|
|
45
|
-
let
|
|
46
|
+
let organization = organizations.get(hostname);
|
|
47
|
+
if (!organization) {
|
|
48
|
+
let org = await crud.readDocument({
|
|
46
49
|
collection: 'organizations',
|
|
47
50
|
filter: {
|
|
48
51
|
query: [
|
|
@@ -52,15 +55,22 @@ class CoCreateFileSystem {
|
|
|
52
55
|
organization_id: process.env.organization_id
|
|
53
56
|
})
|
|
54
57
|
|
|
55
|
-
if (!
|
|
58
|
+
if (!org || !org.document || !org.document[0]) {
|
|
56
59
|
hostNotFound = hostNotFound || 'Organization cannot be found using the host: ' + hostname + ' in platformDB: ' + process.env.organization_id
|
|
57
|
-
|
|
60
|
+
organization = {_id: process.env.organization_id, key: process.env.key}
|
|
61
|
+
// res.redirect(301, '/superadmin/signup.html');
|
|
62
|
+
// if (req.url.startsWith('/superadmin/signup.html'))
|
|
63
|
+
// return res.send(signup);
|
|
64
|
+
// else
|
|
65
|
+
// return res.send(hostNotFound);
|
|
66
|
+
|
|
67
|
+
} else {
|
|
68
|
+
organization = {_id: org.document[0]._id, key: org.document[0].apiKey}
|
|
69
|
+
organizations.set(hostname, organization)
|
|
58
70
|
}
|
|
59
|
-
|
|
60
|
-
organization_id = organization.document[0]._id
|
|
61
|
-
organizations.set(hostname, organization_id)
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
let organization_id = organization._id
|
|
64
74
|
let [url, parameters] = req.url.split("?");
|
|
65
75
|
if (parameters){}
|
|
66
76
|
if (url.endsWith('/')) {
|
|
@@ -153,10 +163,9 @@ class CoCreateFileSystem {
|
|
|
153
163
|
console.warn('server-render: ' + err.message)
|
|
154
164
|
}
|
|
155
165
|
}
|
|
156
|
-
if (url.startsWith('/superadmin')) {
|
|
157
|
-
|
|
158
|
-
src = src.replace(
|
|
159
|
-
console.log('getapikey superadmin')
|
|
166
|
+
if (process.env.organization_id !== organization_id && url.startsWith('/superadmin') && contentType === 'text/html' && !url.includes('/signup.html')) {
|
|
167
|
+
src = src.replace(process.env.organization_id, organization_id)
|
|
168
|
+
src = src.replace(process.env.key, organization.key)
|
|
160
169
|
}
|
|
161
170
|
|
|
162
171
|
return res.type(contentType).send(src);
|