Skip to content

Commit 677923f

Browse files
committed
refactor: change logging to onBeforeHandle
1 parent 12c97ab commit 677923f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const app = new Elysia()
3838
}
3939
})
4040
// Logging
41-
.onAfterResponse(({ path, request }) => {
41+
.onBeforeHandle(({ path, request }) => {
4242
console.log(`🦊 ${request.method} - ${path}`);
4343
})
4444
// Mesure request performance
@@ -57,11 +57,15 @@ const app = new Elysia()
5757
.get(
5858
"/:code",
5959
async ({ params, set, redirect }) => {
60+
console.debug("Redirecting to", params.code);
6061
const link = await getLink(params.code);
62+
console.debug("Link found", link);
6163

6264
if (!link) {
65+
console.debug("Redirecting to", NOT_FOUND_PAGE);
6366
return redirect(`${NOT_FOUND_PAGE}?code=${params.code}`);
6467
} else {
68+
console.debug("Redirecting to", link.url);
6569
set.status = 301;
6670
return redirect(link.url);
6771
}

0 commit comments

Comments
 (0)