@hotmeshio/long-tail 0.4.17 → 0.4.18
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.
|
@@ -117,6 +117,10 @@ class LTExpressAdapter {
|
|
|
117
117
|
// Attach NATS WebSocket proxy (if configured)
|
|
118
118
|
const natsAdapter = events_1.eventRegistry.getAdapter(nats_1.NatsEventAdapter);
|
|
119
119
|
if (natsAdapter?.wsProxyTarget) {
|
|
120
|
+
// Store basePath so the settings endpoint can derive the correct wsUrl
|
|
121
|
+
if (this.basePath) {
|
|
122
|
+
natsAdapter.setWsProxyBasePath(this.basePath);
|
|
123
|
+
}
|
|
120
124
|
(0, nats_ws_proxy_1.attachNatsWsProxy)(server, natsAdapter.wsProxyTarget, {
|
|
121
125
|
basePath: this.basePath,
|
|
122
126
|
onWsUrlDerived: (url) => {
|
package/build/api/settings.js
CHANGED
|
@@ -21,7 +21,7 @@ function resolveNatsWsUrl(adapter, req) {
|
|
|
21
21
|
if (adapter.wsUrl)
|
|
22
22
|
return adapter.wsUrl;
|
|
23
23
|
if (adapter.wsProxyTarget && req) {
|
|
24
|
-
const derived = (0, nats_ws_proxy_1.deriveWsUrlFromRequest)(req);
|
|
24
|
+
const derived = (0, nats_ws_proxy_1.deriveWsUrlFromRequest)(req, adapter.wsProxyBasePath);
|
|
25
25
|
// Cache for future requests and for the proxy's onWsUrlDerived
|
|
26
26
|
adapter.setWsUrl(derived);
|
|
27
27
|
return derived;
|
|
@@ -25,6 +25,7 @@ export declare class NatsEventAdapter implements LTEventAdapter {
|
|
|
25
25
|
private url;
|
|
26
26
|
private _wsUrl;
|
|
27
27
|
private _wsProxyTarget;
|
|
28
|
+
private _wsProxyBasePath;
|
|
28
29
|
private subjectPrefix;
|
|
29
30
|
private token?;
|
|
30
31
|
private originId;
|
|
@@ -46,6 +47,10 @@ export declare class NatsEventAdapter implements LTEventAdapter {
|
|
|
46
47
|
setWsUrl(url: string): void;
|
|
47
48
|
/** Internal NATS WS target for the proxy to bridge to (e.g. ws://nats:9222). */
|
|
48
49
|
get wsProxyTarget(): string | null;
|
|
50
|
+
/** BasePath the proxy is mounted at (e.g. /longtail). Set by LTExpressAdapter. */
|
|
51
|
+
get wsProxyBasePath(): string;
|
|
52
|
+
/** Set the proxy basePath (called by LTExpressAdapter.attachServer). */
|
|
53
|
+
setWsProxyBasePath(basePath: string): void;
|
|
49
54
|
/** NATS auth token for browser connections. */
|
|
50
55
|
get authToken(): string | null;
|
|
51
56
|
/**
|
package/build/lib/events/nats.js
CHANGED
|
@@ -30,6 +30,7 @@ class NatsEventAdapter {
|
|
|
30
30
|
constructor(options) {
|
|
31
31
|
this.nc = null;
|
|
32
32
|
this.sub = null;
|
|
33
|
+
this._wsProxyBasePath = '';
|
|
33
34
|
this.originId = (0, crypto_1.randomUUID)();
|
|
34
35
|
this.callbackAdapter = null;
|
|
35
36
|
this.url = options?.url || config_1.config.NATS_URL;
|
|
@@ -54,6 +55,14 @@ class NatsEventAdapter {
|
|
|
54
55
|
get wsProxyTarget() {
|
|
55
56
|
return this._wsProxyTarget;
|
|
56
57
|
}
|
|
58
|
+
/** BasePath the proxy is mounted at (e.g. /longtail). Set by LTExpressAdapter. */
|
|
59
|
+
get wsProxyBasePath() {
|
|
60
|
+
return this._wsProxyBasePath;
|
|
61
|
+
}
|
|
62
|
+
/** Set the proxy basePath (called by LTExpressAdapter.attachServer). */
|
|
63
|
+
setWsProxyBasePath(basePath) {
|
|
64
|
+
this._wsProxyBasePath = basePath;
|
|
65
|
+
}
|
|
57
66
|
/** NATS auth token for browser connections. */
|
|
58
67
|
get authToken() {
|
|
59
68
|
return this.token || null;
|
|
@@ -18,7 +18,7 @@ router.get('/', async (req, res) => {
|
|
|
18
18
|
// Derive wsUrl from request headers when proxy is active but no URL cached yet
|
|
19
19
|
let wsUrl = natsAdapter.wsUrl;
|
|
20
20
|
if (!wsUrl && natsAdapter.wsProxyTarget) {
|
|
21
|
-
wsUrl = (0, nats_ws_proxy_1.deriveWsUrlFromRequest)(req);
|
|
21
|
+
wsUrl = (0, nats_ws_proxy_1.deriveWsUrlFromRequest)(req, natsAdapter.wsProxyBasePath);
|
|
22
22
|
natsAdapter.setWsUrl(wsUrl);
|
|
23
23
|
}
|
|
24
24
|
res.json({
|
package/package.json
CHANGED