roster-server 1.6.4 → 1.6.8

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.
Files changed (2) hide show
  1. package/index.js +22 -31
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -20,8 +20,6 @@ class Roster {
20
20
  throw new Error('⚠️ Port 80 is reserved for ACME challenge. Please use a different port.');
21
21
  }
22
22
  this.port = port;
23
-
24
- this.loadSites();
25
23
  }
26
24
 
27
25
  async loadSites() {
@@ -31,44 +29,37 @@ class Roster {
31
29
  return;
32
30
  }
33
31
 
34
- const dirents = fs.readdirSync(this.wwwPath, { withFileTypes: true })
35
- .filter(dirent => dirent.isDirectory());
36
-
37
- for (const dirent of dirents) {
38
- const domain = dirent.name;
39
- const domainPath = path.join(this.wwwPath, domain);
32
+ fs.readdirSync(this.wwwPath, { withFileTypes: true })
33
+ .filter(dirent => dirent.isDirectory())
34
+ .forEach(async (dirent) => {
35
+ const domain = dirent.name;
36
+ const domainPath = path.join(this.wwwPath, domain);
40
37
 
41
- const possibleIndexFiles = ['js', 'mjs', 'cjs'].map(ext => `${this.filename}.${ext}`);
42
- let siteApp;
43
- let loadedFile;
38
+ const possibleIndexFiles = ['js', 'mjs', 'cjs'].map(ext => `${this.filename}.${ext}`);
39
+ let siteApp;
40
+ let loadedFile;
44
41
 
45
- for (const indexFile of possibleIndexFiles) {
46
- const indexPath = path.join(domainPath, indexFile);
47
- if (fs.existsSync(indexPath)) {
48
- try {
42
+ for (const indexFile of possibleIndexFiles) {
43
+ const indexPath = path.join(domainPath, indexFile);
44
+ if (fs.existsSync(indexPath)) {
49
45
  siteApp = await import(indexPath);
50
- // If the module has a default export, use that
51
- siteApp = siteApp.default || siteApp;
52
46
  loadedFile = indexFile;
53
47
  break;
54
- } catch (err) {
55
- console.warn(`⚠️ Error loading ${indexPath}:`, err);
56
48
  }
57
49
  }
58
- }
59
50
 
60
- if (siteApp) {
61
- const domainEntries = [domain, `www.${domain}`];
62
- this.domains.push(...domainEntries);
63
- domainEntries.forEach(d => {
64
- this.sites[d] = siteApp;
65
- });
51
+ if (siteApp) {
52
+ const domainEntries = [domain, `www.${domain}`];
53
+ this.domains.push(...domainEntries);
54
+ domainEntries.forEach(d => {
55
+ this.sites[d] = siteApp;
56
+ });
66
57
 
67
- console.log(`✅ Loaded site: ${domain} (using ${loadedFile})`);
68
- } else {
69
- console.warn(`⚠️ No index file (js/mjs/cjs) found in ${domainPath}`);
70
- }
71
- }
58
+ console.log(`✅ Loaded site: ${domain} (using ${loadedFile})`);
59
+ } else {
60
+ console.warn(`⚠️ No index file (js/mjs/cjs) found in ${domainPath}`);
61
+ }
62
+ });
72
63
  }
73
64
 
74
65
  generateConfigJson() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roster-server",
3
- "version": "1.6.4",
3
+ "version": "1.6.8",
4
4
  "description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
5
5
  "main": "index.js",
6
6
  "scripts": {