Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/backend/src/routes/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { hashIp } from '../utils/refreshToken';
import { createCardSchema ,updateCardSchema, addPlatformLinkSchema} from '../validations/card.validation';

import type { CardResponse, UpdateCardBody } from '../services/cardService';
import type { Card } from '@devcard/shared';
import type { Card } from '@devcard/shared/src/types.js';
import type { CardVisibility } from '@prisma/client';
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/routes/follow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getPlatform, getProfileUrl, getWebViewUrl } from '@devcard/shared';
import { getPlatform, getProfileUrl, getWebViewUrl } from '@devcard/shared/src/platforms.js';

import { decrypt } from '../utils/encryption.js';
import { getErrorMessage } from '../utils/error.util.js';
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/routes/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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 {PlatformLink, PublicProfile} from '@devcard/shared/src/types.js'
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';

type TeamMember = PublicProfile & {
Expand All @@ -24,12 +24,12 @@
members: TeamMember[];
}

export async function teamRoutes(app:FastifyInstance){

Check warning on line 27 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
app.post('/', { 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 { const payload = await request.jwtVerify(); if (payload) (request as any).user = payload; } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }

Check failure on line 32 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

'e' is defined but never used. Allowed unused caught errors must match /^_/u

Check failure on line 32 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Expected { after 'if' condition
}] }, async(request:FastifyRequest<{
Body: {name: string, description? : string, avatarUrl?: string }
}>, reply: FastifyReply) => {
Expand All @@ -48,7 +48,7 @@

try {
const team = await app.prisma.$transaction(async (tx) => {
const team = await tx.team.create({

Check failure on line 51 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

'team' is already declared in the upper scope on line 50 column 19
data: {
name,
slug: finalSlug,
Expand Down Expand Up @@ -161,7 +161,7 @@
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 { const payload = await request.jwtVerify(); if (payload) (request as any).user = payload; } catch (e) { reply.status(401).send({ error: 'Unauthorized' }) }

Check failure on line 164 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

'e' is defined but never used. Allowed unused caught errors must match /^_/u

Check failure on line 164 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Expected { after 'if' condition
}] }, async(request: FastifyRequest<{Params: {slug:string}, Body:{username:string}}>, reply: FastifyReply) => {
const paramsSlug = request.params.slug;
const userId = (request.user as any).id;
Expand Down Expand Up @@ -224,7 +224,7 @@
}
})

app.delete('/:slug/members/:userId', { 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' }) } }] }, async(request: FastifyRequest<{Params: {slug: string, userId: string}}>, reply: FastifyReply) => {

Check failure on line 227 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

'e' is defined but never used. Allowed unused caught errors must match /^_/u
const paramsSlug = request.params.slug
const paramsUserId = request.params.userId
const userID = (request.user as any).id;
Expand Down Expand Up @@ -286,7 +286,7 @@
}
})

app.patch('/:slug',{ 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' }) } }] }, async(request: FastifyRequest<{Params: {slug: string},Body: {description?:string, name?:string, avatarUrl?:string}}>, reply: FastifyReply) => {

Check failure on line 289 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

'e' is defined but never used. Allowed unused caught errors must match /^_/u
const userId = (request.user as any).id;
const paramsSlug = request.params.slug;
const parsed = updateTeam.safeParse(request.body);
Expand Down Expand Up @@ -328,7 +328,7 @@

})

app.delete('/:slug',{ 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' }) } }] }, async(request:FastifyRequest<{Params:{slug: string}}>, reply:FastifyReply) => {

Check failure on line 331 in apps/backend/src/routes/team.ts

View workflow job for this annotation

GitHub Actions / backend-ci

'e' is defined but never used. Allowed unused caught errors must match /^_/u
const userId = (request.user as any).id;
const paramsSlug = request.params.slug;

Expand Down
3 changes: 1 addition & 2 deletions apps/backend/src/services/profileService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { FastifyInstance } from 'fastify'

Check failure on line 1 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

`fastify` type import should occur after import of `../utils/error.util.js`

Check failure on line 1 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

There should be at least one empty line between import groups
import { getProfileUrl } from '@devcard/shared'
import type { PlatformLink } from '@devcard/shared'
import { getProfileUrl } from '@devcard/shared/src/platforms.js'
import { getErrorMessage } from '../utils/error.util.js'

export async function getOwnProfile(app: FastifyInstance, userId: string) {

Check warning on line 5 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
const user = await app.prisma.user.findUnique({
where: { id: userId },
include: {
Expand All @@ -18,7 +17,7 @@
return { ...profileData, defaultCardId: user.cards[0]?.id || null }
}

export async function updateProfile(app: FastifyInstance, userId: string, data: any) {

Check warning on line 20 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
// Fast-path uniqueness check
if (data.username) {
const existing = await app.prisma.user.findFirst({
Expand Down Expand Up @@ -48,27 +47,27 @@
}
}

export async function createPlatformLink(app: FastifyInstance, userId: string, linkData: any) {

Check warning on line 50 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
const url = linkData.url || getProfileUrl(linkData.platform, linkData.username)
const maxOrder = await app.prisma.platformLink.aggregate({ where: { userId }, _max: { displayOrder: true } })
return app.prisma.platformLink.create({ data: { userId, platform: linkData.platform, username: linkData.username, url, displayOrder: (maxOrder._max.displayOrder ?? -1) + 1 } })
}

export async function updatePlatformLink(app: FastifyInstance, userId: string, id: string, linkData: any) {

Check warning on line 56 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
const existing = await app.prisma.platformLink.findFirst({ where: { id, userId } })
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) {

Check warning on line 63 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
const existing = await app.prisma.platformLink.findFirst({ where: { id, userId } })
if (!existing) return false
await app.prisma.platformLink.delete({ where: { id } })
return true
}

export async function reorderLinks(app: FastifyInstance, userId: string, links: Array<{ id: string; displayOrder: number }>) {

Check warning on line 70 in apps/backend/src/services/profileService.ts

View workflow job for this annotation

GitHub Actions / backend-ci

Missing return type on function
await app.prisma.$transaction(links.map((link) => app.prisma.platformLink.updateMany({ where: { id: link.id, userId }, data: { displayOrder: link.displayOrder } })))
return { message: 'Links reordered' }
}
2 changes: 1 addition & 1 deletion apps/backend/src/utils/validators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getPlatform } from '@devcard/shared';
import { getPlatform } from '@devcard/shared/src/platforms';
import { z } from 'zod';

export const updateProfileSchema = z.object({
Expand Down
Loading