bxo 0.0.5-dev.1 → 0.0.5-dev.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.ts +33 -7
- package/package.json +1 -1
package/index.ts
CHANGED
@@ -53,7 +53,7 @@ interface LifecycleHooks {
|
|
53
53
|
}
|
54
54
|
|
55
55
|
export default class BXO {
|
56
|
-
private
|
56
|
+
private _routes: Route[] = [];
|
57
57
|
private plugins: BXO[] = [];
|
58
58
|
private hooks: LifecycleHooks = {};
|
59
59
|
private server?: any;
|
@@ -131,7 +131,7 @@ export default class BXO {
|
|
131
131
|
handler: Handler<TConfig>,
|
132
132
|
config?: TConfig
|
133
133
|
): this {
|
134
|
-
this.
|
134
|
+
this._routes.push({ method: 'GET', path, handler, config });
|
135
135
|
return this;
|
136
136
|
}
|
137
137
|
|
@@ -149,7 +149,7 @@ export default class BXO {
|
|
149
149
|
handler: Handler<TConfig>,
|
150
150
|
config?: TConfig
|
151
151
|
): this {
|
152
|
-
this.
|
152
|
+
this._routes.push({ method: 'POST', path, handler, config });
|
153
153
|
return this;
|
154
154
|
}
|
155
155
|
|
@@ -167,7 +167,7 @@ export default class BXO {
|
|
167
167
|
handler: Handler<TConfig>,
|
168
168
|
config?: TConfig
|
169
169
|
): this {
|
170
|
-
this.
|
170
|
+
this._routes.push({ method: 'PUT', path, handler, config });
|
171
171
|
return this;
|
172
172
|
}
|
173
173
|
|
@@ -185,7 +185,7 @@ export default class BXO {
|
|
185
185
|
handler: Handler<TConfig>,
|
186
186
|
config?: TConfig
|
187
187
|
): this {
|
188
|
-
this.
|
188
|
+
this._routes.push({ method: 'DELETE', path, handler, config });
|
189
189
|
return this;
|
190
190
|
}
|
191
191
|
|
@@ -203,13 +203,13 @@ export default class BXO {
|
|
203
203
|
handler: Handler<TConfig>,
|
204
204
|
config?: TConfig
|
205
205
|
): this {
|
206
|
-
this.
|
206
|
+
this._routes.push({ method: 'PATCH', path, handler, config });
|
207
207
|
return this;
|
208
208
|
}
|
209
209
|
|
210
210
|
// Route matching utility
|
211
211
|
private matchRoute(method: string, pathname: string): { route: Route; params: Record<string, string> } | null {
|
212
|
-
for (const route of this.
|
212
|
+
for (const route of this._routes) {
|
213
213
|
if (route.method !== method) continue;
|
214
214
|
|
215
215
|
const routeSegments = route.path.split('/').filter(Boolean);
|
@@ -604,6 +604,32 @@ export default class BXO {
|
|
604
604
|
excludePatterns: Array.from(this.watchedExclude)
|
605
605
|
};
|
606
606
|
}
|
607
|
+
|
608
|
+
// Get server information (alias for getServerInfo)
|
609
|
+
get info() {
|
610
|
+
return {
|
611
|
+
...this.getServerInfo(),
|
612
|
+
totalRoutes: this._routes.length,
|
613
|
+
totalPlugins: this.plugins.length,
|
614
|
+
server: this.server ? 'Bun' : null
|
615
|
+
};
|
616
|
+
}
|
617
|
+
|
618
|
+
// Get all routes information
|
619
|
+
get routes() {
|
620
|
+
return this._routes.map((route: Route) => ({
|
621
|
+
method: route.method,
|
622
|
+
path: route.path,
|
623
|
+
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
|
631
|
+
}));
|
632
|
+
}
|
607
633
|
}
|
608
634
|
|
609
635
|
const error = (error: Error, status: number = 500) => {
|