Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PrismaCrudService
✓ import { PrismaCrudService } from 'nestjs-prisma-crud'
✗ const PrismaCrudService = require('nestjs-prisma-crud').PrismaCrudService
ESM is recommended; CommonJS require still works but may cause issues in ESM-only setups.
AccessPolicy
✓ import { AccessPolicy } from 'nestjs-prisma-crud'
✗ import { AccessPolicyDecorator } from 'nestjs-prisma-crud'
AccessPolicy is a decorator function; ensure it is used as @AccessPolicy(...) on controller methods.
CrudOptions
✓ import type { CrudOptions } from 'nestjs-prisma-crud'
✗ import { CrudOptions } from 'nestjs-prisma-crud'
Type-only import is safe; runtime import may cause issues in production builds.
Shows complete setup: install packages, generate CRUD resource with schematics, create service extending PrismaCrudService, and create controller with @Crud decorator for automatic REST endpoints.
// Install dependencies
// npm i nestjs-prisma-crud
// npm i nestjs-prisma-crud-schematics --save-dev
// Generate CRUD module (replace 'post' with your model name):
// nest g -c nestjs-prisma-crud-schematics crud-resource post
// post.service.ts
import { Injectable } from '@nestjs/common';
import { PrismaCrudService } from 'nestjs-prisma-crud';
@Injectable()
export class PostService extends PrismaCrudService {
constructor() {
super({
model: 'post',
allowedJoins: ['comments.author'],
});
}
}
// post.controller.ts
import { Controller } from '@nestjs/common';
import { CrudController, Crud } from 'nestjs-prisma-crud';
import { PostService } from './post.service';
@Crud({ service: PostService })
@Controller('posts')
export class PostController {
constructor(private readonly postService: PostService) {}
}
Debug
Known issues
breakingVersion 1.0.0-beta.18 is a beta release; breaking changes may occur in future versions without major version bump.fixPin version to exact beta or wait for stable release. Check CHANGELOG before upgrading.
affects: >=1.0.0-beta.0 <=1.0.0-beta.18
gotchaClient-supplied Prisma `where` clauses can be arbitrarily deep. By default, this package validates depth but may still allow complex queries that affect performance.fixConfigure `maxJoinDepth` and `maxWhereDepth` in PrismaCrudService options to limit query complexity.
affects: >=1.0.0-beta.0
gotchaThe `@AccessPolicy` decorator requires manual setup of policy providers. Without proper configuration, all requests may be denied or allowed unexpectedly.fixImplement a custom access policy provider and register it via `APP_GUARD` or global guard.
affects: >=1.0.0-beta.0
deprecatedThe `allowedJoins` option in `PrismaCrudService` may be renamed or restructured in future releases as the API evolves.fixMonitor the repository for changes; use `allowedJoins` as documented but be prepared to migrate.
affects: >=1.0.0-beta.0
Errors
Common errors & fixes
ERROR [ExceptionsHandler] Cannot read property 'name' of undefined
PrismaCrudService model name does not match a generated Prisma model (case-sensitive).
fixEnsure the 'model' value in super({ model: 'post' }) matches exactly the model name in your Prisma schema. Error: @nestjs/schematics not found. Please install @nestjs/schematics.
Missing dependency for NestJS schematics when using crud-resource generator.
fixRun `npm install @nestjs/schematics --save-dev` and then retry the nest g command.
TypeError: Class extends value undefined is not a constructor or null
PrismaCrudService is not imported correctly or the module is not properly loaded.
fixVerify import: import { PrismaCrudService } from 'nestjs-prisma-crud'; and ensure nestjs-prisma-crud is installed. Nest can't resolve dependencies of the CrudController (?). Please make sure that the argument PostService at index [0] is available in the PostModule context.
PostService is not provided in the module's providers array.
fixAdd PostService to the providers array of the module where PostController is declared.
Upgrade
Version history
1.0.0-beta.18latest on npm
Audit
Dependencies
@nestjs/commonrequiredPeer dependency for NestJS decorators and base classes
@nestjs/corerequiredPeer dependency for NestJS core functionality
@prisma/clientrequiredPeer dependency for Prisma ORM integration
reflect-metadatarequiredPeer dependency required by NestJS for decorators
rxjsrequiredPeer dependency for reactive streams in NestJS