roster-server 1.2.0 → 1.2.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.
@@ -0,0 +1,8 @@
1
+ const https = require('https');
2
+
3
+ const server = https.createServer((req, res) => {
4
+ res.writeHead(200);
5
+ res.end('¡Hola desde mi sitio!');
6
+ });
7
+
8
+ module.exports = server;
package/index.js CHANGED
@@ -28,7 +28,10 @@ class Roster {
28
28
  for (const indexFile of possibleIndexFiles) {
29
29
  const indexPath = path.join(domainPath, indexFile);
30
30
  if (fs.existsSync(indexPath)) {
31
- siteApp = require(indexPath);
31
+ const module = require(indexPath);
32
+ // Si el módulo es una función o un servidor, usarlo directamente
33
+ siteApp = typeof module === 'function' ? module :
34
+ (module.handleRequest || module.handle || module);
32
35
  loadedFile = indexFile;
33
36
  break;
34
37
  }
@@ -158,7 +161,12 @@ class Roster {
158
161
  // Find and execute the appropriate site handler
159
162
  const siteApp = this.sites[host];
160
163
  if (siteApp) {
161
- siteApp(req, res);
164
+ // Si es un servidor HTTP/HTTPS, usar su event emitter
165
+ if (siteApp.emit) {
166
+ siteApp.emit('request', req, res);
167
+ } else {
168
+ siteApp(req, res);
169
+ }
162
170
  } else {
163
171
  res.writeHead(404);
164
172
  res.end('Site not found');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roster-server",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
5
5
  "main": "index.js",
6
6
  "scripts": {