Registry / devops / nestjs-prisma-crud

nestjs-prisma-crud

JSON →
library1.0.0-beta.18jsnpmunverified

CRUD utility for NestJS and Prisma ORM (v1.0.0-beta.18, beta stage). Provides automatic REST endpoints for Prisma models with advanced querying (joining, sorting, filtering, pagination), access control via @AccessPolicy decorator, and atomic operations. Ships TypeScript types. Inspired by @nestjsx/crud but tailored for Prisma. Includes a schematic ('crud-resource') for one-line CRUD module scaffolding. Release cadence: irregular, beta status as of Q1 2025. Differentiators: server-side validation of client-provided Prisma where/join clauses, RBAC/ABAC-like policy support via decorators, and tight integration with NestJS and Prisma.

npm install nestjs-prisma-crud
INSTALL
IMPORT
SIG · NESTJS-PRISMA-CRUD
N
nestjs-prisma-crud
devopsjavascriptv1.0.0-beta.18
harness data pending
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.
fix
Pin 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.
fix
Configure `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.
fix
Implement 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.
fix
Monitor 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).
fix
Ensure 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.
fix
Run `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.
fix
Verify 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.
fix
Add 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
Agent activity
2 hits · last 30 days
node
2
Resources
nestjs-prisma-crud — npm install nestjs-prisma-crud · libregistry