User Avatar

Maxime Naulleau

1y ago

Changing a NestJS CRUD API can be time-consuming and boring.

Changes required:

• Database schema

• ORM types

• Repository

• Validation

Here's how to modify a NestJS CRUD API within 1 minute:

1/5

User Avatar

Maxime Naulleau

1y ago

I'm not a big fan of CRUD libraries. They hide logic. Code generation is a handy alternative for instantly changing CRUD APIs.

2/5

User Avatar

Maxime Naulleau

1y ago

1/ Migrations and database access with Prisma

Prisma generates:

• migrations files

• a typesafe client SDK to access the database

Why I don't suggest an alternative is because of its integration with Zod:

3/5

User Avatar

Maxime Naulleau

1y ago

2/ Validation with Zod plugins

Zod plugins do the boring stuff:

zod-prisma => Prisma types to Zod validation

nestjs-graphql-zod => Zod validation to GraphQL validation

prisma-trpc-generator => Prisma to tRPC endpoints with Zod

Then focus on features.

4/5

User Avatar

Maxime Naulleau

1y ago

TL;DR:

Generate:

1/ Migrations and database access with Prisma

2/ Validation with Zod plugins

With that, a few minutes is enough to make many CRUD changes.

5/5

The all-in-one writing platform.

Write, publish everywhere, see what works, and become a better writer - all in one place.

Trusted by 80,000+ writers