Skip to content

Commit

Permalink
Add request log
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore committed Jun 14, 2024
1 parent e3c21ab commit aec5355
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ router.get("/favicon.ico", (ctx) => {
ctx.response.status = 204;
});
router.get("/:iconSlug/:color?/:darkModeColor?", (ctx) => {
const { method, url } = ctx.request;

ctx.response.headers.set(
"Cache-Control",
"public, max-age=86400, s-maxage=31536000, stale-while-revalidate=604800",
Expand All @@ -33,10 +35,13 @@ router.get("/:iconSlug/:color?/:darkModeColor?", (ctx) => {
const iconSvg = getIconSvg(icon, color, darkModeColor, viewbox);
ctx.response.headers.set("Content-Type", "image/svg+xml");
ctx.response.body = iconSvg;
console.log([method, url, 200].join("\t"));
return;
}

return ctx.response.status = 404;
ctx.response.status = 404;
console.log([method, url, 404].join("\t"));
return;
});

const app = new Application();
Expand Down

0 comments on commit aec5355

Please sign in to comment.