@newhomestar/sdk 0.5.1 → 0.5.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/dist/index.d.ts +7 -0
- package/dist/index.js +24 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,13 @@ export declare function generateOpenAPISpec<T extends WorkerDef>(def: T): Promis
|
|
|
126
126
|
export declare function runHttpServer<T extends WorkerDef>(def: T, opts?: {
|
|
127
127
|
port?: number;
|
|
128
128
|
}): void;
|
|
129
|
+
/**
|
|
130
|
+
* Run both HTTP server and queue consumer concurrently
|
|
131
|
+
* This gives you the best of both worlds: direct API access AND event processing
|
|
132
|
+
*/
|
|
133
|
+
export declare function runDualMode<T extends WorkerDef>(def: T, opts?: {
|
|
134
|
+
port?: number;
|
|
135
|
+
}): void;
|
|
129
136
|
export type { ZodTypeAny as SchemaAny, ZodTypeAny };
|
|
130
137
|
export { parseNovaSpec } from "./parseSpec.js";
|
|
131
138
|
export type { NovaSpec } from "./parseSpec.js";
|
package/dist/index.js
CHANGED
|
@@ -366,5 +366,29 @@ export function runHttpServer(def, opts = {}) {
|
|
|
366
366
|
});
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
|
+
/*──────────────── Dual Mode: HTTP + Queue Consumer ───────────────*/
|
|
370
|
+
/**
|
|
371
|
+
* Run both HTTP server and queue consumer concurrently
|
|
372
|
+
* This gives you the best of both worlds: direct API access AND event processing
|
|
373
|
+
*/
|
|
374
|
+
export function runDualMode(def, opts = {}) {
|
|
375
|
+
console.log(`🚀 Worker "${def.name}" starting in DUAL MODE`);
|
|
376
|
+
console.log(`📡 HTTP API + 🎯 Event Queue Consumer`);
|
|
377
|
+
// Start HTTP server
|
|
378
|
+
runHttpServer(def, opts);
|
|
379
|
+
// Start queue consumer (if runtime env vars are available)
|
|
380
|
+
if (process.env.RUNTIME_SUPABASE_URL && process.env.RUNTIME_SUPABASE_KEY) {
|
|
381
|
+
console.log(`🎯 Starting queue consumer for events...`);
|
|
382
|
+
// Run queue consumer in background (don't await)
|
|
383
|
+
runWorker(def).catch((error) => {
|
|
384
|
+
console.error(`[nova] ❌ Queue consumer error:`, error);
|
|
385
|
+
console.error(`[nova] 💡 HTTP server continues running for direct API access`);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
console.warn(`⚠️ RUNTIME_SUPABASE_* env vars not set - queue consumer disabled`);
|
|
390
|
+
console.log(`💡 Worker running in HTTP-only mode. Set RUNTIME_SUPABASE_URL and RUNTIME_SUPABASE_SERVICE_ROLE_KEY to enable event processing`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
369
393
|
// YAML spec parsing utility
|
|
370
394
|
export { parseNovaSpec } from "./parseSpec.js";
|
package/package.json
CHANGED