mirror of
https://github.com/BetterCorp/BetterFrame.git
synced 2026-05-26 17:56:34 +00:00
feat: log 5xx errors to BSB observable via h3 onError
Both admin-http and api-http now log HTTP 500+ errors with status, path, and error message to BSB observable (warn level). Makes server-side errors visible in Coolify/container logs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e189d67faa
commit
0113e4e54a
2 changed files with 26 additions and 2 deletions
|
|
@ -195,7 +195,19 @@ export class Plugin extends BSBService<InstanceType<typeof Config>, typeof Event
|
||||||
otaImportApiKey: this.config.otaImportApiKey || undefined,
|
otaImportApiKey: this.config.otaImportApiKey || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const app = new H3();
|
const app = new H3({
|
||||||
|
onError: (error, event) => {
|
||||||
|
const status = error.status ?? 500;
|
||||||
|
const path = event.req.url ?? "unknown";
|
||||||
|
if (status >= 500) {
|
||||||
|
obs.log.warn("HTTP {status} {path}: {err}", {
|
||||||
|
status,
|
||||||
|
path,
|
||||||
|
err: error.message ?? String(error),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
registerMiddleware(app, deps);
|
registerMiddleware(app, deps);
|
||||||
registerStaticRoutes(app);
|
registerStaticRoutes(app);
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,19 @@ export class Plugin extends BSBService<InstanceType<typeof Config>, typeof Event
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const app = new H3();
|
const app = new H3({
|
||||||
|
onError: (error, event) => {
|
||||||
|
const status = error.status ?? 500;
|
||||||
|
const path = event.req.url ?? "unknown";
|
||||||
|
if (status >= 500) {
|
||||||
|
obs.log.warn("HTTP {status} {path}: {err}", {
|
||||||
|
status,
|
||||||
|
path,
|
||||||
|
err: error.message ?? String(error),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
app.get("/api/kiosk/_check", async (event) => {
|
app.get("/api/kiosk/_check", async (event) => {
|
||||||
const token = extractBearerToken(event);
|
const token = extractBearerToken(event);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue