@getvision/server 0.2.1-d0f3a53-develop → 0.2.1-ec9cf8b-develop
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/package.json +1 -1
- package/src/event-bus.ts +30 -4
package/package.json
CHANGED
package/src/event-bus.ts
CHANGED
|
@@ -26,12 +26,38 @@ export class EventBus {
|
|
|
26
26
|
private devModeHandlers = new Map<string, Array<(data: any) => Promise<void>>>()
|
|
27
27
|
|
|
28
28
|
constructor(config: EventBusConfig = {}) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Build Redis config from environment variables
|
|
30
|
+
const envUrl = process.env.REDIS_URL
|
|
31
|
+
let envRedis: { host?: string; port?: number; password?: string } | undefined
|
|
32
|
+
if (envUrl) {
|
|
33
|
+
try {
|
|
34
|
+
const u = new URL(envUrl)
|
|
35
|
+
envRedis = {
|
|
36
|
+
host: u.hostname || undefined,
|
|
37
|
+
port: u.port ? parseInt(u.port) : 6379,
|
|
38
|
+
// URL password takes precedence over REDIS_PASSWORD
|
|
39
|
+
password: u.password || process.env.REDIS_PASSWORD || undefined,
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
// Fallback to individual env vars if URL is invalid
|
|
43
|
+
envRedis = undefined
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!envRedis) {
|
|
48
|
+
envRedis = {
|
|
32
49
|
host: process.env.REDIS_HOST || 'localhost',
|
|
33
50
|
port: parseInt(process.env.REDIS_PORT || '6379'),
|
|
34
|
-
|
|
51
|
+
password: process.env.REDIS_PASSWORD || undefined,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Merge: explicit config.redis overrides env-derived values
|
|
56
|
+
const mergedRedis = { ...(envRedis || {}), ...(config.redis || {}) }
|
|
57
|
+
|
|
58
|
+
this.config = {
|
|
59
|
+
devMode: config.devMode ?? process.env.NODE_ENV === 'development',
|
|
60
|
+
redis: mergedRedis,
|
|
35
61
|
}
|
|
36
62
|
}
|
|
37
63
|
|