@cocreate/lazy-loader 1.12.2 → 1.13.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,15 @@
1
+ # [1.13.0](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.12.2...v1.13.0) (2023-12-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * create script directory once ([a63b450](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/a63b4508f84ebcdad0f485de75287d2334b548b3))
7
+
8
+
9
+ ### Features
10
+
11
+ * Added '@cocreate/acme' for dynamic ssl management ([5916bd5](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/5916bd53c7165b78274556f5717c84f4c8e1e512))
12
+
1
13
  ## [1.12.2](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.12.1...v1.12.2) (2023-12-28)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/lazy-loader",
3
- "version": "1.12.2",
3
+ "version": "1.13.0",
4
4
  "description": "A simple lazy-loader component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "lazy-loader",
package/src/server.js CHANGED
@@ -11,6 +11,7 @@ class CoCreateLazyLoader {
11
11
  constructor(server, crud, files) {
12
12
  this.server = server
13
13
  this.wsManager = crud.wsManager
14
+ this.acme = crud.wsManager.acme
14
15
  this.crud = crud
15
16
  this.files = files
16
17
  this.exclusion = { ...require.cache };
@@ -19,10 +20,10 @@ class CoCreateLazyLoader {
19
20
  }
20
21
 
21
22
  async init() {
22
- // Function to create the scripts directory if it doesn't exist
23
- async function createScriptsDirectory() {
23
+ const scriptsDirectory = './scripts';
24
+
25
+ if (!await fs.access(scriptsDirectory)) {
24
26
  try {
25
- const scriptsDirectory = './scripts';
26
27
  await fs.mkdir(scriptsDirectory, { recursive: true });
27
28
  console.log(`Scripts directory created at ${scriptsDirectory}`);
28
29
  } catch (error) {
@@ -31,9 +32,6 @@ class CoCreateLazyLoader {
31
32
  }
32
33
  }
33
34
 
34
- // Call this function at the start of your application
35
- createScriptsDirectory();
36
-
37
35
  this.modules = await Config('modules', false, false)
38
36
  if (!this.modules)
39
37
  return
@@ -76,6 +74,8 @@ class CoCreateLazyLoader {
76
74
 
77
75
  hosts[hostname] = organization
78
76
 
77
+ await this.acme.checkCertificate(hostname, organization._id)
78
+
79
79
  if (valideUrl.pathname.startsWith('/webhooks/')) {
80
80
  let name = req.url.split('/')[2]; // Assuming URL structure is /webhook/name/...
81
81
  if (this.modules[name]) {
@@ -94,8 +94,6 @@ class CoCreateLazyLoader {
94
94
  res.writeHead(400, { 'Content-Type': 'text/plain' });
95
95
  res.end('Invalid host format');
96
96
  }
97
-
98
-
99
97
  })
100
98
 
101
99
  }
@@ -188,7 +186,6 @@ class CoCreateLazyLoader {
188
186
 
189
187
  }
190
188
 
191
-
192
189
  }
193
190
 
194
191
  function getModuleDependencies(modulePath) {