From 69c568c2b6e29bc27c869c76dfa517aef1dc9168 Mon Sep 17 00:00:00 2001 From: Prashantkumar Khatri Date: Mon, 22 Jun 2026 00:37:24 +0530 Subject: [PATCH 1/3] refactor: standardize ESM import paths and optimize shared package entry points --- apps/backend/src/routes/cards.ts | 8 ++++---- apps/backend/src/routes/follow.ts | 2 +- apps/backend/src/routes/profiles.ts | 2 +- apps/backend/src/routes/team.ts | 4 ++-- apps/backend/src/services/cardService.ts | 2 +- apps/backend/src/services/profileService.ts | 2 +- apps/backend/src/utils/validators.ts | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/backend/src/routes/cards.ts b/apps/backend/src/routes/cards.ts index a20b4601..694cbec3 100644 --- a/apps/backend/src/routes/cards.ts +++ b/apps/backend/src/routes/cards.ts @@ -1,10 +1,10 @@ import * as cardService from '../services/cardService.js' import { handleDbError } from '../utils/error.util.js'; -import { hashIp } from '../utils/refreshToken'; -import { createCardSchema ,updateCardSchema, addPlatformLinkSchema} from '../validations/card.validation'; +import { hashIp } from '../utils/refreshToken.js'; +import { createCardSchema ,updateCardSchema, addPlatformLinkSchema} from '../validations/card.validation.js'; -import type { CardResponse, UpdateCardBody,UpdatedCardResponse } from '../services/cardService'; -import type { Card } from '@devcard/shared/src/types.js'; +import type { CardResponse, UpdateCardBody, UpdatedCardResponse } from '../services/cardService'; +import type { Card } from '@devcard/shared'; import type { CardVisibility } from '@prisma/client'; import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; diff --git a/apps/backend/src/routes/follow.ts b/apps/backend/src/routes/follow.ts index 1f94a519..0461db3d 100644 --- a/apps/backend/src/routes/follow.ts +++ b/apps/backend/src/routes/follow.ts @@ -1,4 +1,4 @@ -import { getPlatform, getProfileUrl, getWebViewUrl } from '@devcard/shared/src/platforms.js'; +import { getPlatform, getProfileUrl, getWebViewUrl } from '@devcard/shared'; import { decrypt } from '../utils/encryption.js'; import { getErrorMessage } from '../utils/error.util.js'; diff --git a/apps/backend/src/routes/profiles.ts b/apps/backend/src/routes/profiles.ts index 388d3e02..06b1c2c4 100644 --- a/apps/backend/src/routes/profiles.ts +++ b/apps/backend/src/routes/profiles.ts @@ -1,6 +1,6 @@ import { Prisma } from '@prisma/client'; -import * as profileService from '../services/profileService'; +import * as profileService from '../services/profileService.js'; import { updateProfileSchema, createLinkSchema, reorderLinksSchema } from '../utils/validators.js'; import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; diff --git a/apps/backend/src/routes/team.ts b/apps/backend/src/routes/team.ts index 6ab7dfe3..fadad8d9 100644 --- a/apps/backend/src/routes/team.ts +++ b/apps/backend/src/routes/team.ts @@ -4,8 +4,8 @@ import QRCode from 'qrcode' import {generateUniqueSlug} from '../utils/slug.js' import { createTeamScehma,inviteMembers,updateTeam } from '../validations/team.validation.js'; -import type {PlatformLink, PublicProfile} from '@devcard/shared/src/types.js' -import type { FastifyInstance } from 'fastify'; +import type {PlatformLink, PublicProfile} from '@devcard/shared' +import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; type TeamMember = PublicProfile & { teamRole: TeamRole diff --git a/apps/backend/src/services/cardService.ts b/apps/backend/src/services/cardService.ts index 4c83d5b2..cc197e4e 100644 --- a/apps/backend/src/services/cardService.ts +++ b/apps/backend/src/services/cardService.ts @@ -1,7 +1,7 @@ import { type Card, CardVisibility, type Prisma } from '@prisma/client'; import QRCode from 'qrcode'; -import { generateUniqueSlug } from '../utils/slug'; +import { generateUniqueSlug } from '../utils/slug.js'; import type { CreateCardBody } from '../routes/cards'; import type { FastifyInstance } from 'fastify'; diff --git a/apps/backend/src/services/profileService.ts b/apps/backend/src/services/profileService.ts index 4d300091..f84c7eb7 100644 --- a/apps/backend/src/services/profileService.ts +++ b/apps/backend/src/services/profileService.ts @@ -1,5 +1,5 @@ import type { FastifyInstance } from 'fastify' -import { getProfileUrl } from '@devcard/shared/src/platforms.js' +import { getProfileUrl } from '@devcard/shared' import { getErrorMessage } from '../utils/error.util.js' export async function getOwnProfile(app: FastifyInstance, userId: string) { diff --git a/apps/backend/src/utils/validators.ts b/apps/backend/src/utils/validators.ts index 2ec69c1c..0492f6d4 100644 --- a/apps/backend/src/utils/validators.ts +++ b/apps/backend/src/utils/validators.ts @@ -1,4 +1,4 @@ -import { getPlatform } from '@devcard/shared/src/platforms'; +import { getPlatform } from '@devcard/shared'; import { z } from 'zod'; export const updateProfileSchema = z.object({ From c783e48bb28aca19eca55a99cfca7c521f3cd2ad Mon Sep 17 00:00:00 2001 From: Prashantkumar Khatri Date: Tue, 23 Jun 2026 17:16:39 +0530 Subject: [PATCH 2/3] fix(shared): point types to src/index.ts to fix CI typecheck without build --- packages/shared/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/package.json b/packages/shared/package.json index 820641cd..66f6e16a 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "main": "./dist/index.js", - "types": "./dist/index.d.ts", + "types": "./src/index.ts", "scripts": { "build": "tsc", "lint": "eslint src/", From 93e3434151969c9f8aff5aee9035fbc63bb3b111 Mon Sep 17 00:00:00 2001 From: Prashantkumar Khatri Date: Tue, 23 Jun 2026 17:38:17 +0530 Subject: [PATCH 3/3] fix(backend): resolve eslint errors in routes and services --- apps/backend/src/routes/team.ts | 2 +- apps/backend/src/services/profileService.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/backend/src/routes/team.ts b/apps/backend/src/routes/team.ts index fadad8d9..7a372228 100644 --- a/apps/backend/src/routes/team.ts +++ b/apps/backend/src/routes/team.ts @@ -5,7 +5,7 @@ import {generateUniqueSlug} from '../utils/slug.js' import { createTeamScehma,inviteMembers,updateTeam } from '../validations/team.validation.js'; import type {PlatformLink, PublicProfile} from '@devcard/shared' -import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; +import type { FastifyInstance } from 'fastify'; type TeamMember = PublicProfile & { teamRole: TeamRole diff --git a/apps/backend/src/services/profileService.ts b/apps/backend/src/services/profileService.ts index f84c7eb7..385709b1 100644 --- a/apps/backend/src/services/profileService.ts +++ b/apps/backend/src/services/profileService.ts @@ -1,7 +1,9 @@ -import type { FastifyInstance } from 'fastify' import { getProfileUrl } from '@devcard/shared' + import { getErrorMessage } from '../utils/error.util.js' +import type { FastifyInstance } from 'fastify' + export async function getOwnProfile(app: FastifyInstance, userId: string) { const user = await app.prisma.user.findUnique({ where: { id: userId }, @@ -11,9 +13,9 @@ export async function getOwnProfile(app: FastifyInstance, userId: string) { }, }) - if (!user) return null + if (!user) {return null} - const { provider, providerId, ...profileData } = user as any + const { provider: _provider, providerId: _providerId, ...profileData } = user as any return { ...profileData, defaultCardId: user.cards[0]?.id || null } } @@ -23,7 +25,7 @@ export async function updateProfile(app: FastifyInstance, userId: string, data: const existing = await app.prisma.user.findFirst({ where: { username: data.username, NOT: { id: userId } }, }) - if (existing) throw Object.assign(new Error('Username taken'), { code: 'P2002' }) + if (existing) {throw Object.assign(new Error('Username taken'), { code: 'P2002' })} } const currentUser = await app.prisma.user.findUnique({ where: { id: userId }, select: { username: true } }) @@ -41,7 +43,7 @@ export async function updateProfile(app: FastifyInstance, userId: string, data: return response } catch (err: any) { - if (err?.code === 'P2002') throw err + if (err?.code === 'P2002') {throw err} app.log.error({ err }, 'DB error in updateProfile') throw err } @@ -55,14 +57,14 @@ export async function createPlatformLink(app: FastifyInstance, userId: string, l export async function updatePlatformLink(app: FastifyInstance, userId: string, id: string, linkData: any) { const existing = await app.prisma.platformLink.findFirst({ where: { id, userId } }) - if (!existing) return null + if (!existing) {return null} const url = linkData.url || getProfileUrl(linkData.platform, linkData.username) return app.prisma.platformLink.update({ where: { id }, data: { platform: linkData.platform, username: linkData.username, url } }) } export async function deletePlatformLink(app: FastifyInstance, userId: string, id: string) { const existing = await app.prisma.platformLink.findFirst({ where: { id, userId } }) - if (!existing) return false + if (!existing) {return false} await app.prisma.platformLink.delete({ where: { id } }) return true }