bxo 0.0.5-dev.72 → 0.0.5-dev.74
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/example/index.ts +3 -3
- package/package.json +1 -1
- package/src/index.ts +5 -4
package/example/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import index from "./index.html";
|
|
|
3
3
|
import { openapi } from "../plugins/openapi";
|
|
4
4
|
|
|
5
5
|
async function main() {
|
|
6
|
-
const bxo = new BXO();
|
|
6
|
+
const bxo = new BXO({ serve: { port: 0 } });
|
|
7
7
|
|
|
8
8
|
bxo.default("/", index);
|
|
9
9
|
bxo.default("/*", index);
|
|
@@ -136,8 +136,8 @@ async function main() {
|
|
|
136
136
|
|
|
137
137
|
// Health check route
|
|
138
138
|
bxo.get("/health", (ctx) => {
|
|
139
|
-
return ctx.json({
|
|
140
|
-
status: "ok",
|
|
139
|
+
return ctx.json({
|
|
140
|
+
status: "ok",
|
|
141
141
|
timestamp: new Date().toISOString(),
|
|
142
142
|
uptime: process.uptime()
|
|
143
143
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -272,12 +272,13 @@ export default class BXO {
|
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
this.serveOptions.port = this.serveOptions.port === undefined ? 3000 : this.serveOptions.port;
|
|
276
|
+
|
|
275
277
|
this.server = Bun.serve({
|
|
276
278
|
...this.serveOptions,
|
|
277
279
|
routes: nativeRoutes as any,
|
|
278
280
|
fetch: (req: Request) => this.dispatchAny(req, nativeRoutes)
|
|
279
281
|
});
|
|
280
|
-
const port = (this.server as any).port ?? this.serveOptions.port ?? 3000;
|
|
281
282
|
}
|
|
282
283
|
|
|
283
284
|
// Lifecycle hook methods
|
|
@@ -346,7 +347,7 @@ export default class BXO {
|
|
|
346
347
|
try {
|
|
347
348
|
queryObj = route.schema?.query ? parseQuery(url.searchParams, route.schema.query as any) : parseQuery(url.searchParams);
|
|
348
349
|
} catch (err: any) {
|
|
349
|
-
const payload = err?.issues ? { error: "Validation Error", issues: err.issues } : { error: "Validation Error" };
|
|
350
|
+
const payload = err?.issues ? { error: "Validation Error", issues: err.issues } : { error: "Validation Error", issues: [], message: err.message };
|
|
350
351
|
return new Response(JSON.stringify(payload), { status: 400, headers: { "Content-Type": "application/json" } });
|
|
351
352
|
}
|
|
352
353
|
|
|
@@ -385,7 +386,7 @@ export default class BXO {
|
|
|
385
386
|
return new Response(JSON.stringify({ error: "Body is required" }), { status: 400, headers: { "Content-Type": "application/json" } });
|
|
386
387
|
}
|
|
387
388
|
} catch (err: any) {
|
|
388
|
-
const payload = err?.issues ? { error: "Validation Error", issues: err.issues } : { error: "Validation Error" };
|
|
389
|
+
const payload = err?.issues ? { error: "Validation Error", issues: err.issues } : { error: "Validation Error", issues: [], message: err.message };
|
|
389
390
|
return new Response(JSON.stringify(payload), { status: 400, headers: { "Content-Type": "application/json" } });
|
|
390
391
|
}
|
|
391
392
|
|
|
@@ -454,7 +455,7 @@ export default class BXO {
|
|
|
454
455
|
(route.schema.cookies as any).parse(cookieObj);
|
|
455
456
|
}
|
|
456
457
|
} catch (err: any) {
|
|
457
|
-
const payload = err?.issues ? { error: "Validation Error", issues: err.issues } : { error: "Validation Error" };
|
|
458
|
+
const payload = err?.issues ? { error: "Validation Error", issues: err.issues } : { error: "Validation Error", issues: [], message: err.message };
|
|
458
459
|
return new Response(JSON.stringify(payload), { status: 400, headers: { "Content-Type": "application/json" } });
|
|
459
460
|
}
|
|
460
461
|
}
|