vibex-sh 0.9.0 → 0.9.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.
- package/index.js +24 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -66,7 +66,7 @@ function deriveSocketUrl(webUrl) {
|
|
|
66
66
|
// For vibex.sh domains, use Workers WebSocket endpoint
|
|
67
67
|
else if (url.hostname.includes('vibex.sh')) {
|
|
68
68
|
// Use Cloudflare Workers WebSocket endpoint
|
|
69
|
-
const workerUrl = process.env.VIBEX_WORKER_URL || 'https://vibex-ingest.
|
|
69
|
+
const workerUrl = process.env.VIBEX_WORKER_URL || 'https://vibex-ingest.prop.workers.dev';
|
|
70
70
|
return workerUrl.replace('https://', 'wss://').replace('http://', 'ws://');
|
|
71
71
|
}
|
|
72
72
|
// For other domains, derive from web URL
|
|
@@ -112,9 +112,11 @@ function getUrls(options) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// Priority 5: Production defaults
|
|
115
|
+
// Use Worker WebSocket endpoint instead of old Socket.io server
|
|
116
|
+
const defaultWorkerUrl = process.env.VIBEX_WORKER_URL || 'https://vibex-ingest.prop.workers.dev';
|
|
115
117
|
return {
|
|
116
118
|
webUrl: 'https://vibex.sh',
|
|
117
|
-
socketUrl: socket || 'https://
|
|
119
|
+
socketUrl: socket || defaultWorkerUrl.replace('https://', 'wss://').replace('http://', 'ws://'),
|
|
118
120
|
};
|
|
119
121
|
}
|
|
120
122
|
|
|
@@ -549,13 +551,21 @@ async function main() {
|
|
|
549
551
|
}
|
|
550
552
|
|
|
551
553
|
try {
|
|
552
|
-
//
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
554
|
+
// Determine ingest URL
|
|
555
|
+
let ingestUrl;
|
|
556
|
+
if (webUrl.includes('localhost') || webUrl.includes('127.0.0.1')) {
|
|
557
|
+
// Local development - use Workers dev server
|
|
558
|
+
ingestUrl = 'http://localhost:8787/api/v1/ingest';
|
|
559
|
+
} else if (process.env.VIBEX_WORKER_URL) {
|
|
560
|
+
// Use explicit Worker URL if set
|
|
561
|
+
ingestUrl = `${process.env.VIBEX_WORKER_URL}/api/v1/ingest`;
|
|
562
|
+
} else {
|
|
563
|
+
// Production default - use Worker URL (not web URL)
|
|
564
|
+
const defaultWorkerUrl = 'https://vibex-ingest.prop.workers.dev';
|
|
565
|
+
ingestUrl = `${defaultWorkerUrl}/api/v1/ingest`;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
console.log(` 📤 Sending log to: ${ingestUrl}`);
|
|
559
569
|
|
|
560
570
|
const response = await fetch(ingestUrl, {
|
|
561
571
|
method: 'POST',
|
|
@@ -571,6 +581,7 @@ async function main() {
|
|
|
571
581
|
|
|
572
582
|
if (!response.ok) {
|
|
573
583
|
const errorData = await response.json().catch(() => ({}));
|
|
584
|
+
console.error(` ✗ HTTP ${response.status}: ${errorData.message || response.statusText}`);
|
|
574
585
|
if (response.status === 429) {
|
|
575
586
|
console.error('\n ⚠️ Rate Limit Exceeded');
|
|
576
587
|
console.error(` ${errorData.message || 'Too many requests. Please try again later.'}`);
|
|
@@ -584,9 +595,12 @@ async function main() {
|
|
|
584
595
|
}
|
|
585
596
|
console.error('');
|
|
586
597
|
}
|
|
598
|
+
} else {
|
|
599
|
+
const result = await response.json().catch(() => ({}));
|
|
600
|
+
console.log(` ✓ Log sent successfully (processed: ${result.processed || 1})`);
|
|
587
601
|
}
|
|
588
602
|
} catch (error) {
|
|
589
|
-
console.error(
|
|
603
|
+
console.error(` ✗ Error sending log to ${ingestUrl}:`, error.message);
|
|
590
604
|
}
|
|
591
605
|
};
|
|
592
606
|
|