bxo 0.0.5-dev.2 → 0.0.5-dev.4
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.ts +44 -10
- package/package.json +1 -1
package/index.ts
CHANGED
@@ -3,6 +3,18 @@ import { z } from 'zod';
|
|
3
3
|
// Type utilities for extracting types from Zod schemas
|
4
4
|
type InferZodType<T> = T extends z.ZodType<infer U> ? U : never;
|
5
5
|
|
6
|
+
// OpenAPI detail information
|
7
|
+
interface RouteDetail {
|
8
|
+
summary?: string;
|
9
|
+
description?: string;
|
10
|
+
tags?: string[];
|
11
|
+
operationId?: string;
|
12
|
+
deprecated?: boolean;
|
13
|
+
produces?: string[];
|
14
|
+
consumes?: string[];
|
15
|
+
[key: string]: any; // Allow additional OpenAPI properties
|
16
|
+
}
|
17
|
+
|
6
18
|
// Configuration interface for route handlers
|
7
19
|
interface RouteConfig {
|
8
20
|
params?: z.ZodSchema<any>;
|
@@ -10,6 +22,7 @@ interface RouteConfig {
|
|
10
22
|
body?: z.ZodSchema<any>;
|
11
23
|
headers?: z.ZodSchema<any>;
|
12
24
|
response?: z.ZodSchema<any>;
|
25
|
+
detail?: RouteDetail;
|
13
26
|
}
|
14
27
|
|
15
28
|
// Context type that's fully typed based on the route configuration
|
@@ -61,6 +74,8 @@ export default class BXO {
|
|
61
74
|
private hotReloadEnabled: boolean = false;
|
62
75
|
private watchedFiles: Set<string> = new Set();
|
63
76
|
private watchedExclude: Set<string> = new Set();
|
77
|
+
private serverPort?: number;
|
78
|
+
private serverHostname?: string;
|
64
79
|
|
65
80
|
constructor() { }
|
66
81
|
|
@@ -501,6 +516,8 @@ export default class BXO {
|
|
501
516
|
});
|
502
517
|
|
503
518
|
this.isRunning = true;
|
519
|
+
this.serverPort = port;
|
520
|
+
this.serverHostname = hostname;
|
504
521
|
|
505
522
|
console.log(`🦊 BXO server running at http://${hostname}:${port}`);
|
506
523
|
|
@@ -545,6 +562,8 @@ export default class BXO {
|
|
545
562
|
}
|
546
563
|
|
547
564
|
this.isRunning = false;
|
565
|
+
this.serverPort = undefined;
|
566
|
+
this.serverHostname = undefined;
|
548
567
|
|
549
568
|
console.log('🛑 BXO server stopped');
|
550
569
|
|
@@ -608,10 +627,31 @@ export default class BXO {
|
|
608
627
|
// Get server information (alias for getServerInfo)
|
609
628
|
get info() {
|
610
629
|
return {
|
611
|
-
|
630
|
+
// Server status
|
631
|
+
running: this.isRunning,
|
632
|
+
server: this.server ? 'Bun' : null,
|
633
|
+
|
634
|
+
// Connection details
|
635
|
+
hostname: this.serverHostname,
|
636
|
+
port: this.serverPort,
|
637
|
+
url: this.isRunning && this.serverHostname && this.serverPort
|
638
|
+
? `http://${this.serverHostname}:${this.serverPort}`
|
639
|
+
: null,
|
640
|
+
|
641
|
+
// Application statistics
|
612
642
|
totalRoutes: this._routes.length,
|
613
643
|
totalPlugins: this.plugins.length,
|
614
|
-
|
644
|
+
|
645
|
+
// Hot reload configuration
|
646
|
+
hotReload: this.hotReloadEnabled,
|
647
|
+
watchedFiles: Array.from(this.watchedFiles),
|
648
|
+
excludePatterns: Array.from(this.watchedExclude),
|
649
|
+
|
650
|
+
// System information
|
651
|
+
runtime: 'Bun',
|
652
|
+
version: typeof Bun !== 'undefined' ? Bun.version : 'unknown',
|
653
|
+
pid: process.pid,
|
654
|
+
uptime: this.isRunning ? process.uptime() : 0
|
615
655
|
};
|
616
656
|
}
|
617
657
|
|
@@ -621,13 +661,7 @@ export default class BXO {
|
|
621
661
|
method: route.method,
|
622
662
|
path: route.path,
|
623
663
|
hasConfig: !!route.config,
|
624
|
-
config: route.config
|
625
|
-
hasParams: !!route.config.params,
|
626
|
-
hasQuery: !!route.config.query,
|
627
|
-
hasBody: !!route.config.body,
|
628
|
-
hasHeaders: !!route.config.headers,
|
629
|
-
hasResponse: !!route.config.response
|
630
|
-
} : null
|
664
|
+
config: route.config || null
|
631
665
|
}));
|
632
666
|
}
|
633
667
|
}
|
@@ -640,4 +674,4 @@ const error = (error: Error, status: number = 500) => {
|
|
640
674
|
export { z, error };
|
641
675
|
|
642
676
|
// Export types for external use
|
643
|
-
export type { RouteConfig, Handler };
|
677
|
+
export type { RouteConfig, RouteDetail, Handler };
|