roster-server 1.6.4 → 1.6.6

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 +25 -33
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -31,44 +31,37 @@ class Roster {
31
31
  return;
32
32
  }
33
33
 
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);
40
-
41
- const possibleIndexFiles = ['js', 'mjs', 'cjs'].map(ext => `${this.filename}.${ext}`);
42
- let siteApp;
43
- let loadedFile;
44
-
45
- for (const indexFile of possibleIndexFiles) {
46
- const indexPath = path.join(domainPath, indexFile);
47
- if (fs.existsSync(indexPath)) {
48
- try {
34
+ fs.readdirSync(this.wwwPath, { withFileTypes: true })
35
+ .filter(dirent => dirent.isDirectory())
36
+ .forEach(async (dirent) => {
37
+ const domain = dirent.name;
38
+ const domainPath = path.join(this.wwwPath, domain);
39
+
40
+ const possibleIndexFiles = ['js', 'mjs', 'cjs'].map(ext => `${this.filename}.${ext}`);
41
+ let siteApp;
42
+ let loadedFile;
43
+
44
+ for (const indexFile of possibleIndexFiles) {
45
+ const indexPath = path.join(domainPath, indexFile);
46
+ if (fs.existsSync(indexPath)) {
49
47
  siteApp = await import(indexPath);
50
- // If the module has a default export, use that
51
- siteApp = siteApp.default || siteApp;
52
48
  loadedFile = indexFile;
53
49
  break;
54
- } catch (err) {
55
- console.warn(`⚠️ Error loading ${indexPath}:`, err);
56
50
  }
57
51
  }
58
- }
59
52
 
60
- if (siteApp) {
61
- const domainEntries = [domain, `www.${domain}`];
62
- this.domains.push(...domainEntries);
63
- domainEntries.forEach(d => {
64
- this.sites[d] = siteApp;
65
- });
53
+ if (siteApp) {
54
+ const domainEntries = [domain, `www.${domain}`];
55
+ this.domains.push(...domainEntries);
56
+ domainEntries.forEach(d => {
57
+ this.sites[d] = siteApp;
58
+ });
66
59
 
67
- console.log(`✅ Loaded site: ${domain} (using ${loadedFile})`);
68
- } else {
69
- console.warn(`⚠️ No index file (js/mjs/cjs) found in ${domainPath}`);
70
- }
71
- }
60
+ console.log(`✅ Loaded site: ${domain} (using ${loadedFile})`);
61
+ } else {
62
+ console.warn(`⚠️ No index file (js/mjs/cjs) found in ${domainPath}`);
63
+ }
64
+ });
72
65
  }
73
66
 
74
67
  generateConfigJson() {
@@ -196,8 +189,7 @@ class Roster {
196
189
  console.log(`✅ Manually registered site: ${domain}`);
197
190
  }
198
191
 
199
- async start() {
200
- await this.loadSites();
192
+ start() {
201
193
  this.generateConfigJson();
202
194
 
203
195
  const greenlock = Greenlock.init({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roster-server",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
5
5
  "main": "index.js",
6
6
  "scripts": {