@cocreate/lazy-loader 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 +14 -0
- package/package.json +1 -1
- package/src/server.js +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.11.2](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.11.1...v1.11.2) (2023-12-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* this.modules ([7839c7f](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/7839c7f73e68f967a20613ffe53b1b3deb4f7f62))
|
|
7
|
+
|
|
8
|
+
## [1.11.1](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.11.0...v1.11.1) (2023-12-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* hosts.get() converted to object ([c21187b](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/c21187ba2209bae5565078cd8fb1a7fea0b22b4c))
|
|
14
|
+
|
|
1
15
|
# [1.11.0](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.10.0...v1.11.0) (2023-12-09)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -37,12 +37,13 @@ class CoCreateLazyLoader {
|
|
|
37
37
|
// TODO: return the value so it can be applied directly to modules
|
|
38
38
|
// this.modules[key] = await Config('modules', false, false)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
if (!
|
|
40
|
+
this.modules = await Config('modules', false, false)
|
|
41
|
+
if (!this.modules)
|
|
42
42
|
return
|
|
43
|
+
else
|
|
44
|
+
this.modules = this.modules.modules
|
|
43
45
|
|
|
44
|
-
for (let name of Object.keys(
|
|
45
|
-
this.modules[name] = config.modules[name];
|
|
46
|
+
for (let name of Object.keys(this.modules)) {
|
|
46
47
|
this.wsManager.on(this.modules[name].event, async (data) => {
|
|
47
48
|
this.executeScriptWithTimeout(name, data)
|
|
48
49
|
});
|
|
@@ -53,7 +54,7 @@ class CoCreateLazyLoader {
|
|
|
53
54
|
const valideUrl = new URL(`http://${req.headers.host}${req.url}`);
|
|
54
55
|
const hostname = valideUrl.hostname;
|
|
55
56
|
|
|
56
|
-
let organization = hosts
|
|
57
|
+
let organization = hosts[hostname];
|
|
57
58
|
if (!organization) {
|
|
58
59
|
let org = await this.crud.send({
|
|
59
60
|
method: 'object.read',
|
|
@@ -73,14 +74,15 @@ class CoCreateLazyLoader {
|
|
|
73
74
|
} else {
|
|
74
75
|
organization = org.object[0]
|
|
75
76
|
organizations[organization._id] = organization
|
|
76
|
-
hosts[hostname] = organization
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
hosts[hostname] = organization
|
|
81
|
+
|
|
80
82
|
if (valideUrl.pathname.startsWith('/webhooks/')) {
|
|
81
83
|
let name = req.url.split('/')[2]; // Assuming URL structure is /webhook/name/...
|
|
82
84
|
if (this.modules[name]) {
|
|
83
|
-
this.executeScriptWithTimeout(name, { req, res, crud: this.crud, organization, valideUrl })
|
|
85
|
+
this.executeScriptWithTimeout(name, { req, res, crud: this.crud, organization, valideUrl, organization_id: data.organization })
|
|
84
86
|
} else {
|
|
85
87
|
// Handle unknown module or missing webhook method
|
|
86
88
|
res.writeHead(404, { 'Content-Type': 'application/json' });
|