Skip to content

Commit c122569

Browse files
fix: resolve implicit any in event attendees mapping (#214)
* fix: standardize error handling in follow route * fix: resolve implicit any in event attendees mapping * fix: resolve implicit any in attendee map with Prisma type --------- Signed-off-by: Pari Maheshwari <parimaheshwari777@gmail.com>
1 parent 0d43ebc commit c122569

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

apps/backend/src/routes/event.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
22
import { createEventSchema, joinEventSchema} from '../validations/event.validation';
3+
import { Prisma } from '@prisma/client';
34

45
type EventDetails = {
56
id: string;
@@ -35,6 +36,27 @@ type PaginatedAttendeesResponse = {
3536
};
3637
}
3738

39+
type EventWithAttendees = Prisma.EventGetPayload<{
40+
include: {
41+
attendees: {
42+
include: {
43+
user: {
44+
select: {
45+
id: true;
46+
username: true;
47+
displayName: true;
48+
bio: true;
49+
pronouns: true;
50+
company: true;
51+
avatarUrl: true;
52+
accentColor: true;
53+
};
54+
};
55+
};
56+
};
57+
};
58+
}>;
59+
3860
export async function eventRoutes(app:FastifyInstance) {
3961
app.post('/' , async(request: FastifyRequest<{
4062
Body: {
@@ -244,14 +266,14 @@ export async function eventRoutes(app:FastifyInstance) {
244266
orderBy: {joinedAt: 'desc'}
245267
}
246268
},
247-
})
269+
})as EventWithAttendees | null;
248270

249271
if(!event){
250272
return reply.status(404).send({error: 'Event not found'})
251273
}
252274

253275

254-
const attendees = event.attendees.map(attendee => ({
276+
const attendees = event.attendees.map((attendee: EventWithAttendees['attendees'][number]) => ({
255277
id: attendee.user.id,
256278
username: attendee.user.username,
257279
displayName: attendee.user.displayName,

0 commit comments

Comments
 (0)