Quickstart
info
This guide assumes you have already setup NestJS and Prisma. See Getting Started if you haven't.
Install
nestjs-prisma-crud
andnestjs-prisma-crud-schematics
:npm i nestjs-prisma-crud --savenpm i nestjs-prisma-crud-schematics --save-dev
Register the module:
app.module.tsimport { PrismaCrudModule } from 'nestjs-prisma-crud'; @Module({ imports: [ /** * PrismaCrudModule registers the PrismaService provider globally. * No need to provide it anywhere else! */ PrismaCrudModule.register({ prismaService: PrismaService, }), ], // ...})export class AppModule {}
Generate the entire crud module with the following command (replace post with your table's name from your Prisma schema):
nest g -c nestjs-prisma-crud-schematics crud-resource post
Start the server and verify installation:
npm run start:devcurl http://localhost:3000/post # 200 response json object