@cocreate/file-server 1.2.0 → 1.3.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 CHANGED
@@ -1,3 +1,23 @@
1
+ # [1.3.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.2.1...v1.3.0) (2023-05-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * apikey renamed to key ([3cd1648](https://github.com/CoCreate-app/CoCreate-file-server/commit/3cd16488b21b0110ec242b1c02dffe02328153c9))
7
+ * replace key ([fa78c05](https://github.com/CoCreate-app/CoCreate-file-server/commit/fa78c0557c380e149336b4eefbe8e797b86b3409))
8
+
9
+
10
+ ### Features
11
+
12
+ * redirect to /superadmin ([9094337](https://github.com/CoCreate-app/CoCreate-file-server/commit/909433742d08dadb1bc9f61b45850dd6eec8e1c2))
13
+
14
+ ## [1.2.1](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.2.0...v1.2.1) (2023-05-10)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * handeling of superadmin signup ([06a5b96](https://github.com/CoCreate-app/CoCreate-file-server/commit/06a5b963bd8f552d02baa3ac9f749071a8387653))
20
+
1
21
  # [1.2.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.1.3...v1.2.0) (2023-05-05)
2
22
 
3
23
 
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  "config": {
3
- "apiKey": "2061acef-0451-4545-f754-60cf8160",
3
+ "key": "2061acef-0451-4545-f754-60cf8160",
4
4
  "organization_id": "5ff747727005da1c272740ab",
5
5
  "host": "general.cocreate.app"
6
6
  },
package/docs/index.html CHANGED
@@ -92,7 +92,7 @@
92
92
  </div>
93
93
  <script>
94
94
  var CoCreateConfig = {
95
- apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
95
+ key: '2061acef-0451-4545-f754-60cf8160',
96
96
  organization_id: '5ff747727005da1c272740ab'
97
97
  }
98
98
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/file-server",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A simple file-server component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "file-server",
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 organization_id = organizations.get(hostname);
44
- if (!organization_id) {
45
- let organization = await crud.readDocument({
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,18 @@ class CoCreateFileSystem {
52
55
  organization_id: process.env.organization_id
53
56
  })
54
57
 
55
- if (!organization || !organization.document || !organization.document[0]) {
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
- return res.send(hostNotFound);
60
+ organization = {_id: process.env.organization_id, key: process.env.key}
61
+ if (!req.url.startsWith('/superadmin'))
62
+ return res.redirect(301, 'https://' + hostname + '/superadmin/signup.html')
63
+ } else {
64
+ organization = {_id: org.document[0]._id, key: org.document[0].key}
65
+ organizations.set(hostname, organization)
58
66
  }
59
-
60
- organization_id = organization.document[0]._id
61
- organizations.set(hostname, organization_id)
62
67
  }
63
68
 
69
+ let organization_id = organization._id
64
70
  let [url, parameters] = req.url.split("?");
65
71
  if (parameters){}
66
72
  if (url.endsWith('/')) {
@@ -153,10 +159,9 @@ class CoCreateFileSystem {
153
159
  console.warn('server-render: ' + err.message)
154
160
  }
155
161
  }
156
- if (url.startsWith('/superadmin')) {
157
- let apikey = "e968b3a6-435e-4d79-a251-b41d7d08"
158
- src = src.replace('5ff747727005da1c272740ab', organization_id).replace('2061acef-0451-4545-f754-60cf8160', apikey)
159
- console.log('getapikey superadmin')
162
+ if (process.env.organization_id !== organization_id && url.startsWith('/superadmin') && contentType === 'text/html' && !url.includes('/signup.html')) {
163
+ src = src.replace(process.env.organization_id, organization_id)
164
+ src = src.replace(process.env.key, organization.key)
160
165
  }
161
166
 
162
167
  return res.type(contentType).send(src);