Improvement for quieting routes

This commit is contained in:
Dominic Ferrando
2026-10-04 00:12:24 -04:00
parent 0576421368
commit 3ef0c9e88f
+7 -8
View File
@@ -36,6 +36,7 @@ import { VerificationsService, VerificationStatusSchema } from "./services/verif
const EVENT_QUEUE_MANAGE_DELAY_MS = 1000 // 1 sec const EVENT_QUEUE_MANAGE_DELAY_MS = 1000 // 1 sec
const JWT_EXP = "1d"; const JWT_EXP = "1d";
const JWT_EXP_SECONDS = 60 * 60 * 24; // keep in sync with JWT_EXP; used for cookie maxAge const JWT_EXP_SECONDS = 60 * 60 * 24; // keep in sync with JWT_EXP; used for cookie maxAge
const QUIET_ROUTES = new Set(["GET /commerce/products/sync/"]); // logged at debug level
// SERVICES // SERVICES
// ----------------------- // -----------------------
@@ -142,16 +143,12 @@ export const app = new Elysia()
} }
}) })
.onAfterResponse(({ request, set, path, responseValue }) => { .onAfterResponse(({ request, route, set, responseValue }) => {
if (env.NODE_ENV === "development") {
const skip: Record<string, string[]> = { "/commerce/products/sync/": ["GET"] };
if (skip[path]?.includes(request.method)) return;
}
const failed = Number(set.status) >= 400; const failed = Number(set.status) >= 400;
log[failed ? "warn" : "info"]({ const level = failed ? "warn" : QUIET_ROUTES.has(`${request.method} ${route}`) ? "debug" : "info";
log[level]({
method: request.method, method: request.method,
path, path: route,
status: set.status, status: set.status,
...(failed && { response: responseValue }), ...(failed && { response: responseValue }),
}, "request"); }, "request");
@@ -296,6 +293,8 @@ export const app = new Elysia()
}) })
) )
) )
// STANDARDS
.group("/standards", { authAdmin: true }, (app) => app .group("/standards", { authAdmin: true }, (app) => app
.post("/configs", async ({ body: { name, datasetId, params } }) => { .post("/configs", async ({ body: { name, datasetId, params } }) => {
return await s.Standards.Configs.create(name, datasetId, params); return await s.Standards.Configs.create(name, datasetId, params);