@cocreate/file-server 1.0.53 → 1.1.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 +7 -0
- package/package.json +1 -1
- package/src/index.js +18 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.1.0](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.53...v1.1.0) (2023-04-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* store organizaton_id in map to prevent repeated db queries ([74c0540](https://github.com/CoCreate-app/CoCreate-file-server/commit/74c05407df2118a9b1601181a7a42c1ac7bdad32))
|
|
7
|
+
|
|
1
8
|
## [1.0.53](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.0.52...v1.0.53) (2023-04-11)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -4,23 +4,32 @@
|
|
|
4
4
|
*
|
|
5
5
|
* SPDX-License-Identifier: MIT
|
|
6
6
|
********************************************************************************/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const express = require('express');
|
|
8
|
+
const router = express.Router();
|
|
9
|
+
const mime = require('mime-types');
|
|
10
|
+
const organizations = new Map();
|
|
11
|
+
|
|
12
12
|
class CoCreateFileSystem {
|
|
13
13
|
constructor(crud, render) {
|
|
14
14
|
this.router = router.get('/*', async(req, res) => {
|
|
15
|
-
let organization_id;
|
|
16
15
|
let hostname = req.hostname;
|
|
16
|
+
|
|
17
|
+
let organization_id = organizations.get(hostname);
|
|
18
|
+
console.log(req.protocol, req.secure)
|
|
19
|
+
// let ddns = await certManager.checkDns(hostname)
|
|
20
|
+
// let hasCert = await certManager.checkCert(hostname)
|
|
21
|
+
// console.log(hostname, 'crt==', hasCert)
|
|
22
|
+
// ToDo: check if secured domain by running command
|
|
23
|
+
// sudo certbot certificates using spawn
|
|
24
|
+
// console.dir(req.headers.host)
|
|
17
25
|
// dns.resolve(hostname, 'TXT', (err, records) => {
|
|
18
26
|
// if (records)
|
|
19
27
|
// organization_id = records[0][0];
|
|
20
28
|
// if (err)
|
|
21
29
|
// console.log(hostname, err);
|
|
22
30
|
// });
|
|
23
|
-
|
|
31
|
+
|
|
32
|
+
|
|
24
33
|
if (!organization_id) {
|
|
25
34
|
let organization = await crud.readDocument({
|
|
26
35
|
collection: 'organizations',
|
|
@@ -32,9 +41,10 @@ class CoCreateFileSystem {
|
|
|
32
41
|
organization_id: process.env.organization_id
|
|
33
42
|
})
|
|
34
43
|
if (!organization || !organization.document || !organization.document[0])
|
|
35
|
-
return res.send('Organization cannot be found using the host
|
|
44
|
+
return res.send('Organization cannot be found using the host---: ' + hostname + ' in platformDB: ' + process.env.organization_id);
|
|
36
45
|
|
|
37
46
|
organization_id = organization.document[0]._id
|
|
47
|
+
organizations.set(hostname, organization_id)
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
let [url, parameters] = req.url.split("?");
|