notiz-dev / nestjs-prisma

Easy Prisma support for your NestJS application
https://nestjs-prisma.dev
MIT License
587 stars 50 forks source link

Use PrismaClientExceptionFilter get error `response.status(...).json is not a function` when FastifyAdapter as app #20

Closed liaosankai closed 2 years ago

liaosankai commented 2 years ago

I got error response.status(...).json is not a function in PrismaClientExceptionFilter if I use FastifyAdapter as my app. How about compatible with fastify?

marcjulian commented 2 years ago

@liaosankai thanks for reporting this issue. I haven't used it with fastify yet, but makes sense that you receive the error as the filter uses Response from express https://github.com/notiz-dev/nestjs-prisma/blob/main/lib/prisma-client-exception.filter.ts#L4.

We should add an exception filter for fastify for examle PrismaClientFasitfyExceptionFilter. Here is an example how to get and manipulate the response for fastify.

Do you want to add this filter for fastify in a PR? Happy to help out.