@donkeylabs/server 2.0.15 → 2.0.16
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/server.ts +10 -6
package/package.json
CHANGED
package/src/server.ts
CHANGED
|
@@ -210,6 +210,7 @@ export class AppServer {
|
|
|
210
210
|
// Custom services registry
|
|
211
211
|
private serviceFactories = new Map<string, ServiceFactory<any>>();
|
|
212
212
|
private serviceRegistry: Record<string, any> = {};
|
|
213
|
+
private generateModeTimer?: ReturnType<typeof setTimeout>;
|
|
213
214
|
|
|
214
215
|
constructor(options: ServerConfig) {
|
|
215
216
|
// Port priority: explicit config > PORT env var > default 3000
|
|
@@ -500,15 +501,18 @@ export class AppServer {
|
|
|
500
501
|
use(router: IRouter): this {
|
|
501
502
|
this.routers.push(router);
|
|
502
503
|
|
|
503
|
-
//
|
|
504
|
+
// Handle CLI type generation mode with debounced timer
|
|
504
505
|
// This handles SvelteKit-style entry files that don't call start()
|
|
505
|
-
if (
|
|
506
|
-
|
|
507
|
-
//
|
|
508
|
-
|
|
506
|
+
if (process.env.DONKEYLABS_GENERATE === "1") {
|
|
507
|
+
// Clear any existing timer and set a new one
|
|
508
|
+
// This ensures we wait for all use() calls to complete
|
|
509
|
+
if (this.generateModeTimer) {
|
|
510
|
+
clearTimeout(this.generateModeTimer);
|
|
511
|
+
}
|
|
512
|
+
this.generateModeTimer = setTimeout(() => {
|
|
509
513
|
this.outputRoutesForGeneration();
|
|
510
514
|
process.exit(0);
|
|
511
|
-
});
|
|
515
|
+
}, 100); // 100ms debounce - waits for all route registrations
|
|
512
516
|
}
|
|
513
517
|
|
|
514
518
|
return this;
|