From c2c898cba56aebac0c94602ab0b130b8a810ad65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 14:13:06 +0000 Subject: [PATCH 1/3] Initial plan From 19333d3a2641c07d0ab78726de3e9cd8e4e94ff1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 14:16:04 +0000 Subject: [PATCH 2/3] Replace @ts-ignore with proper type narrowing for vote parameter Co-authored-by: Jan0707 <1663330+Jan0707@users.noreply.github.com> --- nuxt-app/server/middleware/rating.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nuxt-app/server/middleware/rating.ts b/nuxt-app/server/middleware/rating.ts index 68ebae9..c3ead34 100644 --- a/nuxt-app/server/middleware/rating.ts +++ b/nuxt-app/server/middleware/rating.ts @@ -14,7 +14,15 @@ export default eventHandler(async function(event) { } let slug = match[1]; - let vote = match[2]; + let voteString = match[2]; + + // Type narrowing: the regex already validated this is "up" or "down" + // We use a type guard to make TypeScript aware of this + if (voteString !== 'up' && voteString !== 'down') { + // This should never happen due to regex validation, but satisfies TypeScript + throw createError({ statusCode: 400, message: 'Invalid vote value' }); + } + const vote: "up" | "down" = voteString; const directus = useDirectus(); @@ -24,7 +32,6 @@ export default eventHandler(async function(event) { throw createError({ statusCode: 404, message: 'Podcast not found' }); } - // @ts-ignore (Type-safety is enforced by regex) try { await directus.createRating(vote, podcast); From 654072e8f160b82cbdee6dd1ebeec0e2ce1387d2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 14:17:23 +0000 Subject: [PATCH 3/3] Remove redundant type assertion after type guard Co-authored-by: Jan0707 <1663330+Jan0707@users.noreply.github.com> --- nuxt-app/server/middleware/rating.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuxt-app/server/middleware/rating.ts b/nuxt-app/server/middleware/rating.ts index c3ead34..663465c 100644 --- a/nuxt-app/server/middleware/rating.ts +++ b/nuxt-app/server/middleware/rating.ts @@ -22,7 +22,7 @@ export default eventHandler(async function(event) { // This should never happen due to regex validation, but satisfies TypeScript throw createError({ statusCode: 400, message: 'Invalid vote value' }); } - const vote: "up" | "down" = voteString; + const vote = voteString; const directus = useDirectus();