refactor(server): changed to log only when in dev, and removed the redirect of the url

This commit is contained in:
2025-03-25 07:40:15 -05:00
parent 5149de3199
commit adf0880659

View File

@@ -39,7 +39,10 @@ createLog("info", "LST", "server", `Server is installed: ${installed}`);
const app = new OpenAPIHono({ strict: false }); const app = new OpenAPIHono({ strict: false });
// middle ware // middle ware
app.use("*", logger()); if (process.env.NODE_ENV === "development") {
app.use("*", logger());
}
app.use( app.use(
"*", "*",
cors({ cors({
@@ -53,17 +56,17 @@ app.use(
); );
// Middleware to normalize route case // Middleware to normalize route case
app.use("*", async (c, next) => { // app.use("*", async (c, next) => {
const lowercasedUrl = c.req.url.toLowerCase(); // // const lowercasedUrl = c.req.url.toLowerCase();
//console.log("Incoming Request:", c.req.url, c.req.method); // console.log("Incoming Request:", c.req.url, c.req.method);
// If the URL is already lowercase, continue as usual // // // If the URL is already lowercase, continue as usual
if (c.req.url === lowercasedUrl) { // // if (c.req.url === lowercasedUrl) {
return next(); // await next();
} // // }
// Otherwise, re-route internally // // // Otherwise, re-route internally
return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method // // return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method
}); // });
app.doc("/api/ref", { app.doc("/api/ref", {
openapi: "3.0.0", openapi: "3.0.0",