From a9a1a85f4da9ec20e0c272626db169d4f6eee548 Mon Sep 17 00:00:00 2001 From: Dasari Keerthana Date: Sun, 21 Jun 2026 00:54:17 +0530 Subject: [PATCH 1/3] fix(backend): remove any usages from cards.ts --- apps/backend/src/routes/cards.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/backend/src/routes/cards.ts b/apps/backend/src/routes/cards.ts index 050a1676..c450f92c 100644 --- a/apps/backend/src/routes/cards.ts +++ b/apps/backend/src/routes/cards.ts @@ -50,11 +50,11 @@ interface _CardWithLinks { export async function cardRoutes(app: FastifyInstance): Promise { app.addHook('preHandler', async (request, reply) => { - const server = request.server as any; - if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return } - if (typeof (app as any).authenticate === 'function') { await (app as any).authenticate(request, reply); return } - try { await request.jwtVerify() } catch (_e) { reply.status(401).send({ error: 'Unauthorized' }) } - }); + const server = request.server; + if (typeof server?.authenticate === 'function') { await server.authenticate(request, reply); return } + if (typeof app.authenticate === 'function') { await app.authenticate(request, reply); return } + try { await request.jwtVerify() } catch (_e) { reply.status(401).send({ error: 'Unauthorized' }) } +}); // ─── List Cards ─── @@ -80,7 +80,7 @@ export async function cardRoutes(app: FastifyInstance): Promise { try { const card = await cardService.createCard(app, userId, parsed.data) return reply.status(201).send(card) - } catch (error: any) { + } catch (error: unknown) { if (error?.code === 'OWNERSHIP') {return reply.status(403).send({ error: 'One or more links do not belong to your account' })} return handleDbError(error, request, reply) } @@ -98,7 +98,7 @@ export async function cardRoutes(app: FastifyInstance): Promise { const updated = await cardService.updateCard(app, userId, id, parsed.data) if (!updated) {return reply.status(404).send({ error: 'Card not found' })} return updated - } catch (error: any) { + } catch (error: unknown) { if (error?.code === 'OWNERSHIP') {return reply.status(403).send({ error: 'One or more links do not belong to your account' })} return handleDbError(error, request, reply) } @@ -113,7 +113,7 @@ export async function cardRoutes(app: FastifyInstance): Promise { try { await cardService.deleteCard(app, userId, id) return reply.status(204).send() - } catch (error:any) { + } catch (error: unknown) { if (error?.code === 'NOT_FOUND') { return reply.status(404).send({ error: 'Card not found' }); } From d00d432dfef172f1ed5448d31181e473bcfcc7cc Mon Sep 17 00:00:00 2001 From: Dasari Keerthana Date: Sun, 21 Jun 2026 01:42:23 +0530 Subject: [PATCH 2/3] fix: handle unknown errors in cards route --- apps/backend/src/routes/cards.ts | 41 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/apps/backend/src/routes/cards.ts b/apps/backend/src/routes/cards.ts index c450f92c..3197ef2f 100644 --- a/apps/backend/src/routes/cards.ts +++ b/apps/backend/src/routes/cards.ts @@ -80,10 +80,17 @@ export async function cardRoutes(app: FastifyInstance): Promise { try { const card = await cardService.createCard(app, userId, parsed.data) return reply.status(201).send(card) - } catch (error: unknown) { - if (error?.code === 'OWNERSHIP') {return reply.status(403).send({ error: 'One or more links do not belong to your account' })} - return handleDbError(error, request, reply) - } + } catch (error: unknown) { + const err = error as { code?: string }; + + if (err.code === 'OWNERSHIP') { + return reply.status(403).send({ + error: 'One or more links do not belong to your account', + }); + } + + return handleDbError(error, request, reply); + } }); // ─── Update Card ─── @@ -98,10 +105,17 @@ export async function cardRoutes(app: FastifyInstance): Promise { const updated = await cardService.updateCard(app, userId, id, parsed.data) if (!updated) {return reply.status(404).send({ error: 'Card not found' })} return updated - } catch (error: unknown) { - if (error?.code === 'OWNERSHIP') {return reply.status(403).send({ error: 'One or more links do not belong to your account' })} - return handleDbError(error, request, reply) - } + } catch (error: unknown) { + const err = error as { code?: string }; + + if (err.code === 'OWNERSHIP') { + return reply.status(403).send({ + error: 'One or more links do not belong to your account', + }); + } + + return handleDbError(error, request, reply); + } }); // ─── Delete Card ─── @@ -114,17 +128,20 @@ export async function cardRoutes(app: FastifyInstance): Promise { await cardService.deleteCard(app, userId, id) return reply.status(204).send() } catch (error: unknown) { - if (error?.code === 'NOT_FOUND') { + const err = error as { code?: string }; + + if (err.code === 'NOT_FOUND') { return reply.status(404).send({ error: 'Card not found' }); } - if (error?.code === 'LAST_CARD') { + if (err.code === 'LAST_CARD') { return reply.status(400).send({ error: 'Cannot delete the last remaining card. A user must have at least one card.', }); } - return handleDbError(error, request, reply) - } + + return handleDbError(error, request, reply); + } }); // ─── Set Default Card ─── From c5a4c77e1bf1c5f45104ee80a19a27588696debc Mon Sep 17 00:00:00 2001 From: Dasari Keerthana Date: Tue, 23 Jun 2026 18:56:21 +0530 Subject: [PATCH 3/3] ci: build shared package before backend typecheck --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71aedeb6..5bb7a5e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,12 @@ jobs: - name: Install backend dependencies run: npm --prefix apps/backend install + - name: Install shared dependencies + run: npm --prefix packages/shared install + - name: Build shared package + run: npm --prefix packages/shared run build + - name: DB migration check if: needs.detect-changes.outputs.dbFiles != '' continue-on-error: true