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..7a372228 100644 --- a/apps/backend/src/routes/team.ts +++ b/apps/backend/src/routes/team.ts @@ -4,7 +4,7 @@ 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 {PlatformLink, PublicProfile} from '@devcard/shared' import type { FastifyInstance } from 'fastify'; type TeamMember = PublicProfile & { 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..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/src/platforms.js' +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 } 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({ 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/",