Skip to content

Blog refresh: NestJS + Prisma series parts 2-5 (Prisma 7 / NestJS 11)#8034

Merged
ankur-arch merged 4 commits into
mainfrom
blog/refresh-nestjs-parts-2-5
Jul 8, 2026
Merged

Blog refresh: NestJS + Prisma series parts 2-5 (Prisma 7 / NestJS 11)#8034
ankur-arch merged 4 commits into
mainfrom
blog/refresh-nestjs-parts-2-5

Conversation

@vanrensbird

@vanrensbird vanrensbird commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

Refreshes the remaining four posts of the NestJS + Prisma series (nestjs-prisma-rest-api) for Prisma ORM 7.8 and NestJS 11, completing the series update started with part 1 in #7977:

  • Part 2: Input Validation & Transformation (nestjs-prisma-validation-7D056s1kOla1)
  • Part 3: Error Handling (nestjs-prisma-error-handling-7D056s1kOop2)
  • Part 4: Handling Relational Data (nestjs-prisma-relational-data-7D056s1kOabc)
  • Part 5: Authentication (nestjs-prisma-authentication-7D056s1s0k3l)

Slugs, Tasin Ishmam's byline, and original publish dates are preserved; updatedAt: 2026-07-08 added.

Verification

The tutorial project was rebuilt from refreshed part 1 and every step of parts 2-5 was executed against prisma@7.8 / @nestjs/core@11 with a live Prisma Postgres database. All error/response JSON in the posts is pasted from real responses: validation 400s, whitelist stripping (and the pre-whitelist date-injection exploit), ParseIntPipe rejection, unhandled P2002 500 → filter 409, users CRUD with password exclusion via ClassSerializerInterceptor, include: { author } serialization, and the full JWT login flow with bcrypt hashing.

Notable changes beyond version bumps

  • Prisma 7 correctness: Prisma namespace and model types import from the generated client (generated/prisma/client), not @prisma/client; an explicit npx prisma generate step after migrate dev (on 7.8 migrate dev does not regenerate the client; verified twice).
  • strictNullChecks fixes: the old code no longer compiles on NestJS 11 defaults (UserEntity.name is now string | null, ArticleEntity.author is UserEntity | null, null-handling on findOne).
  • Linear series: each part now continues from the previous one; the companion repo clone instructions were removed (that repo is still Prisma 4 / NestJS 8) with a note explaining why.
  • Part 2 got a review pass from Martin applied as the series template: inline TOC removed (the layout renders its own), answer-first lead, FAQ as <Accordions> (bodies server-rendered), first product mentions linked to docs, Prisma Next pull-quote replaced with a short plain closing note (applied to all four parts).
  • Nest CLI 11 filter path (src/prisma-client-exception/…), docker compose syntax, tsx seed runner, current package set (bcrypt@6, @nestjs/passport@11).

Notes for review

  • Recommend merging Refresh: Building a REST API with NestJS and Prisma (Prisma 7 / NestJS 11) #7977 (part 1) first; these posts link to it as the updated starting point. Part 1 also still claims migrate dev regenerates the client and carries the old TOC/pull-quote; it needs the same small sweep.
  • Parts 3-5 intentionally have not yet received the part-2 template treatment (TOC removal etc. beyond the Prisma Next note); Martin is reviewing them next and the sweep will follow his remarks.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated several NestJS/Prisma tutorial posts for the latest stack versions, with refreshed dates, SEO metadata, and revised walkthroughs.
    • Improved authentication guidance with JWT login, protected routes, Swagger bearer auth, and hashed password handling.
    • Expanded error-handling content to show clearer 404 and 409 responses, plus updated Prisma exception handling.
    • Revised validation and relational-data tutorials with stronger examples for request validation, route parsing, user/article relations, and safer response serialization.

vanrensbird and others added 4 commits July 8, 2026 12:19
All code verified end-to-end on prisma@7.8 + @nestjs/core@11 against a real
Prisma Postgres database (validation 400s, whitelist stripping, ParseIntPipe,
P2002 409 filter, users CRUD, password exclusion, author include, full JWT
login flow, bcrypt hashing).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…, web-repo blog skill conventions

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ll 4 parts)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vanrensbird vanrensbird requested a review from ankur-arch July 8, 2026 10:19
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Jul 8, 2026 10:21am
docs Ready Ready Preview, Comment Jul 8, 2026 10:21am
eclipse Ready Ready Preview, Comment Jul 8, 2026 10:21am
site Ready Ready Preview, Comment Jul 8, 2026 10:21am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Four Prisma/NestJS blog tutorials (authentication, error handling, relational data, validation) were updated for Prisma ORM 7 and NestJS 11. Changes include refreshed front matter, narrative rewrites, JWT auth with bcrypt hashing, a Prisma-based exception filter, User/Article relations with password exclusion, and ValidationPipe/whitelist/ParseIntPipe documentation.

Changes

Authentication Tutorial

Layer / File(s) Summary
Intro and setup refresh
apps/blog/content/blog/nestjs-prisma-authentication-.../index.mdx
Front matter and intro/setup sections updated for the new stack versions.
Auth module and login flow
apps/blog/content/blog/nestjs-prisma-authentication-.../index.mdx
Documents LoginDto, AuthEntity, AuthModule with JwtModule, and AuthService.login/AuthController wiring.
JWT strategy and route guarding
apps/blog/content/blog/nestjs-prisma-authentication-.../index.mdx
Adds JwtStrategy, JwtAuthGuard applied to UsersController routes, and Swagger bearer auth.
Bcrypt password hashing
apps/blog/content/blog/nestjs-prisma-authentication-.../index.mdx
Updates UsersService and seed script to hash passwords, and AuthService.login to use bcrypt.compare.

Error Handling Tutorial

Layer / File(s) Summary
Intro refresh
apps/blog/content/blog/nestjs-prisma-error-handling-.../index.mdx
Front matter and setup narrative updated for Prisma 7 client conventions.
404 handling in findOne
apps/blog/content/blog/nestjs-prisma-error-handling-.../index.mdx
Updates findOne with ParseIntPipe, async/await, and NotFoundException.
Global exception filter
apps/blog/content/blog/nestjs-prisma-error-handling-.../index.mdx
Rewrites PrismaClientExceptionFilter to handle P2002 with 409 responses and wires it globally via HttpAdapterHost.

Relational Data Tutorial

Layer / File(s) Summary
Schema and seed updates
apps/blog/content/blog/nestjs-prisma-relational-data-.../index.mdx
Adds User model and Article author/authorId relation, updates seed script accordingly.
ArticleEntity authorId
apps/blog/content/blog/nestjs-prisma-relational-data-.../index.mdx
Extends ArticleEntity with an authorId field.
Users CRUD resource
apps/blog/content/blog/nestjs-prisma-relational-data-.../index.mdx
Adds UsersModule, UsersService using PrismaService, CreateUserDto, and UsersController.
Password exclusion
apps/blog/content/blog/nestjs-prisma-relational-data-.../index.mdx
Registers ClassSerializerInterceptor globally and adds @Exclude() on UserEntity.password.
Nested author serialization
apps/blog/content/blog/nestjs-prisma-relational-data-.../index.mdx
Includes author relation in ArticlesService.findOne and nests UserEntity within ArticleEntity.

Validation Tutorial

Layer / File(s) Summary
Intro refresh
apps/blog/content/blog/nestjs-prisma-validation-.../index.mdx
Front matter and setup content updated for the new stack.
Global ValidationPipe
apps/blog/content/blog/nestjs-prisma-validation-.../index.mdx
Documents app.useGlobalPipes(new ValidationPipe()) and CreateArticleDto's role.
Whitelist stripping
apps/blog/content/blog/nestjs-prisma-validation-.../index.mdx
Updates to ValidationPipe({ whitelist: true }) with illustrations of stripped fields.
ParseIntPipe and FAQ
apps/blog/content/blog/nestjs-prisma-validation-.../index.mdx
Replaces manual id casting with ParseIntPipe and adds an FAQ accordion.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: refreshing parts 2-5 of the NestJS + Prisma blog series for Prisma 7 and NestJS 11.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ankur-arch ankur-arch merged commit 8ae77a7 into main Jul 8, 2026
14 of 16 checks passed
@ankur-arch ankur-arch deleted the blog/refresh-nestjs-parts-2-5 branch July 8, 2026 10:22
@argos-ci

argos-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 8, 2026, 10:28 AM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/blog/content/blog/nestjs-prisma-error-handling-7D056s1kOop2/index.mdx (1)

284-284: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider tightening "many different kinds of errors".

"many different kinds of" is wordy. A simpler phrasing like "various errors" reads more cleanly.

✏️ Suggested rewording
-Prisma throws the `PrismaClientKnownRequestError` for many different kinds of errors.
+Prisma throws the `PrismaClientKnownRequestError` for various errors.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/blog/content/blog/nestjs-prisma-error-handling-7D056s1kOop2/index.mdx`
at line 284, Tighten the phrasing in the PrismaClientKnownRequestError
explanation by replacing the wordy “many different kinds of errors” with a
shorter alternative like “various errors” in the surrounding markdown text.
Update the sentence in the blog content so it reads more cleanly while keeping
the rest of the PrismaClientKnownRequestError and code property explanation
unchanged.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/blog/content/blog/nestjs-prisma-error-handling-7D056s1kOop2/index.mdx`:
- Around line 255-323: The P2002 branch in PrismaClientExceptionFilter is
exposing raw Prisma error details to clients. Update the catch method so it
still logs exception.message server-side, but returns a generic conflict
response for the P2002 case instead of using the raw exception.message in the
JSON payload. Keep the existing switch on exception.code in
PrismaClientExceptionFilter and adjust the response.status(...).json(...)
payload to use a user-friendly message while preserving the default super.catch
fallback for other Prisma errors.

In `@apps/blog/content/blog/nestjs-prisma-relational-data-7D056s1kOabc/index.mdx`:
- Line 790: Update the wording in the affected prose to hyphenate the compound
adjective “Prisma-generated types” instead of “Prisma generated types.” Locate
the sentence discussing ArticlesController, ArticleEntity, and
ClassSerializerInterceptor, and make the small text-only grammar correction
without changing any technical meaning.

In `@apps/blog/content/blog/nestjs-prisma-validation-7D056s1kOla1/index.mdx`:
- Line 39: The Node.js prerequisite in the tutorial is outdated and should be
raised to match the stack. Update the requirement text in the blog content to
specify Node.js v20 or higher instead of v18 or higher, and keep the wording
consistent with the setup instructions in this article.

---

Nitpick comments:
In `@apps/blog/content/blog/nestjs-prisma-error-handling-7D056s1kOop2/index.mdx`:
- Line 284: Tighten the phrasing in the PrismaClientKnownRequestError
explanation by replacing the wordy “many different kinds of errors” with a
shorter alternative like “various errors” in the surrounding markdown text.
Update the sentence in the blog content so it reads more cleanly while keeping
the rest of the PrismaClientKnownRequestError and code property explanation
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fe67be97-db82-4f30-843c-8498c1051a9e

📥 Commits

Reviewing files that changed from the base of the PR and between 52fe2bb and d564be4.

📒 Files selected for processing (4)
  • apps/blog/content/blog/nestjs-prisma-authentication-7D056s1s0k3l/index.mdx
  • apps/blog/content/blog/nestjs-prisma-error-handling-7D056s1kOop2/index.mdx
  • apps/blog/content/blog/nestjs-prisma-relational-data-7D056s1kOabc/index.mdx
  • apps/blog/content/blog/nestjs-prisma-validation-7D056s1kOla1/index.mdx

Comment on lines +255 to +323

> **Note**: There is a second file created called `src/prisma-client-exception/prisma-client-exception.filter.spec.ts` for creating tests. You can ignore this file for now.

You will get an error from `eslint` since the `catch` method is empty. Update the `catch` method implementation in `PrismaClientExceptionFilter` as follows:

```typescript
// src/prisma-client-exception.filter.ts
```ts
// src/prisma-client-exception/prisma-client-exception.filter.ts

+import { ArgumentsHost, Catch } from '@nestjs/common';
+import { BaseExceptionFilter } from '@nestjs/core';
+import { Prisma } from '@prisma/client';
import { ArgumentsHost, Catch } from '@nestjs/common';
import { BaseExceptionFilter } from '@nestjs/core';
import { Prisma } from '../../generated/prisma/client';

+@Catch(Prisma.PrismaClientKnownRequestError) // 1
+export class PrismaClientExceptionFilter extends BaseExceptionFilter { // 2
+ catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) {
+ console.error(exception.message); // 3
@Catch(Prisma.PrismaClientKnownRequestError) // 1
export class PrismaClientExceptionFilter extends BaseExceptionFilter { // 2
catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) {
console.error(exception.message); // 3

// default 500 error code
+ super.catch(exception, host);
super.catch(exception, host);
}
}
```

Here you have made the following changes:

1. To ensure that this filter catches exceptions of type `PrismaClientKnownRequestError`, you added it to the `@Catch` decorator.
1. To ensure that this filter catches exceptions of type `PrismaClientKnownRequestError`, you added it to the `@Catch` decorator. Note the import: in Prisma 7, the `Prisma` namespace comes from your generated Client (`../../generated/prisma/client`), the same import path you used for the `Article` type in part one. Importing it from `@prisma/client` no longer works.
2. The exception filter extends the `BaseExceptionFilter` class from the NestJS core package. This class provides a default implementation for the `catch` method that returns an "Internal server error" response to the user. You can learn more about this [in the NestJS docs](https://docs.nestjs.com/exception-filters#inheritance).
3. You added a `console.error` statement to log the error message to the console. This is useful for debugging purposes.

Prisma throws the `PrismaClientKnownRequestError` for many different kinds of errors. So you will need to figure out how to extract the error code from the `PrismaClientKnownRequestError` exception. The `PrismaClientKnownRequestError` exception has a `code` property that contains the error code. You can find the list of error codes in the [Prisma Error Message reference](https://www.prisma.io/docs/orm/reference/error-reference#prisma-client-query-engine).
Prisma throws the `PrismaClientKnownRequestError` for many different kinds of errors. So you will need to figure out how to extract the error code from the `PrismaClientKnownRequestError` exception. The `PrismaClientKnownRequestError` exception has a `code` property that contains the error code. You can find the list of error codes in the [Prisma error message reference](https://www.prisma.io/docs/orm/reference/error-reference).

The error code you are looking for is `P2002`, which occurs for unique constraint violations. You will now update the `catch` method to throw an HTTP `409 Conflict` response in case of this error. You will also provide a custom error message to the user.


Update your exception filter implementation like this:

```typescript
//src/prisma-client-exception.filter.ts
```ts
// src/prisma-client-exception/prisma-client-exception.filter.ts

+import { ArgumentsHost, Catch, HttpStatus } from '@nestjs/common';
import { ArgumentsHost, Catch, HttpStatus } from '@nestjs/common';
import { BaseExceptionFilter } from '@nestjs/core';
import { Prisma } from '@prisma/client';
+import { Response } from 'express';
import { Prisma } from '../../generated/prisma/client';
import { Response } from 'express';

@Catch(Prisma.PrismaClientKnownRequestError)
export class PrismaClientExceptionFilter extends BaseExceptionFilter {
catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) {
console.error(exception.message);
+ const ctx = host.switchToHttp();
+ const response = ctx.getResponse<Response>();
+ const message = exception.message.replace(/\n/g, '');

+ switch (exception.code) {
+ case 'P2002': {
+ const status = HttpStatus.CONFLICT;
+ response.status(status).json({
+ statusCode: status,
+ message: message,
+ });
+ break;
+ }
+ default:
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const message = exception.message.replace(/\n/g, '');

switch (exception.code) {
case 'P2002': {
const status = HttpStatus.CONFLICT;
response.status(status).json({
statusCode: status,
message: message,
});
break;
}
default:
// default 500 error code
super.catch(exception, host);
+ break;
+ }
break;
}
}
}
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

The P2002 response leaks internal file paths and query text to the client.

The message variable at line 304 is the raw exception.message, which includes internal paths (~/median/src/articles/articles.service.ts:11:32) and Prisma query internals. The example response at line 383 confirms this — the entire Prisma error trace is sent to the API consumer. While line 326 includes a general cautionary note, the tutorial's own example demonstrates the leak, and readers may copy it verbatim into production code.

Consider using a generic message for the P2002 case (e.g., "A record with this title already exists") and logging the detailed message server-side only. This also makes the example response cleaner and more instructive.

🛡️ Suggested improvement
       case 'P2002': {
         const status = HttpStatus.CONFLICT;
         response.status(status).json({
           statusCode: status,
-          message: message,
+          message: 'A record with this value already exists.',
         });
         break;
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
> **Note**: There is a second file created called `src/prisma-client-exception/prisma-client-exception.filter.spec.ts` for creating tests. You can ignore this file for now.
You will get an error from `eslint` since the `catch` method is empty. Update the `catch` method implementation in `PrismaClientExceptionFilter` as follows:
```typescript
// src/prisma-client-exception.filter.ts
```ts
// src/prisma-client-exception/prisma-client-exception.filter.ts
+import { ArgumentsHost, Catch } from '@nestjs/common';
+import { BaseExceptionFilter } from '@nestjs/core';
+import { Prisma } from '@prisma/client';
import { ArgumentsHost, Catch } from '@nestjs/common';
import { BaseExceptionFilter } from '@nestjs/core';
import { Prisma } from '../../generated/prisma/client';
+@Catch(Prisma.PrismaClientKnownRequestError) // 1
+export class PrismaClientExceptionFilter extends BaseExceptionFilter { // 2
+ catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) {
+ console.error(exception.message); // 3
@Catch(Prisma.PrismaClientKnownRequestError) // 1
export class PrismaClientExceptionFilter extends BaseExceptionFilter { // 2
catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) {
console.error(exception.message); // 3
// default 500 error code
+ super.catch(exception, host);
super.catch(exception, host);
}
}
```
Here you have made the following changes:
1. To ensure that this filter catches exceptions of type `PrismaClientKnownRequestError`, you added it to the `@Catch` decorator.
1. To ensure that this filter catches exceptions of type `PrismaClientKnownRequestError`, you added it to the `@Catch` decorator. Note the import: in Prisma 7, the `Prisma` namespace comes from your generated Client (`../../generated/prisma/client`), the same import path you used for the `Article` type in part one. Importing it from `@prisma/client` no longer works.
2. The exception filter extends the `BaseExceptionFilter` class from the NestJS core package. This class provides a default implementation for the `catch` method that returns an "Internal server error" response to the user. You can learn more about this [in the NestJS docs](https://docs.nestjs.com/exception-filters#inheritance).
3. You added a `console.error` statement to log the error message to the console. This is useful for debugging purposes.
Prisma throws the `PrismaClientKnownRequestError` for many different kinds of errors. So you will need to figure out how to extract the error code from the `PrismaClientKnownRequestError` exception. The `PrismaClientKnownRequestError` exception has a `code` property that contains the error code. You can find the list of error codes in the [Prisma Error Message reference](https://www.prisma.io/docs/orm/reference/error-reference#prisma-client-query-engine).
Prisma throws the `PrismaClientKnownRequestError` for many different kinds of errors. So you will need to figure out how to extract the error code from the `PrismaClientKnownRequestError` exception. The `PrismaClientKnownRequestError` exception has a `code` property that contains the error code. You can find the list of error codes in the [Prisma error message reference](https://www.prisma.io/docs/orm/reference/error-reference).
The error code you are looking for is `P2002`, which occurs for unique constraint violations. You will now update the `catch` method to throw an HTTP `409 Conflict` response in case of this error. You will also provide a custom error message to the user.
Update your exception filter implementation like this:
```typescript
//src/prisma-client-exception.filter.ts
```ts
// src/prisma-client-exception/prisma-client-exception.filter.ts
+import { ArgumentsHost, Catch, HttpStatus } from '@nestjs/common';
import { ArgumentsHost, Catch, HttpStatus } from '@nestjs/common';
import { BaseExceptionFilter } from '@nestjs/core';
import { Prisma } from '@prisma/client';
+import { Response } from 'express';
import { Prisma } from '../../generated/prisma/client';
import { Response } from 'express';
@Catch(Prisma.PrismaClientKnownRequestError)
export class PrismaClientExceptionFilter extends BaseExceptionFilter {
catch(exception: Prisma.PrismaClientKnownRequestError, host: ArgumentsHost) {
console.error(exception.message);
+ const ctx = host.switchToHttp();
+ const response = ctx.getResponse<Response>();
+ const message = exception.message.replace(/\n/g, '');
+ switch (exception.code) {
+ case 'P2002': {
+ const status = HttpStatus.CONFLICT;
+ response.status(status).json({
+ statusCode: status,
+ message: message,
+ });
+ break;
+ }
+ default:
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const message = exception.message.replace(/\n/g, '');
switch (exception.code) {
case 'P2002': {
const status = HttpStatus.CONFLICT;
response.status(status).json({
statusCode: status,
message: message,
});
break;
}
default:
// default 500 error code
super.catch(exception, host);
+ break;
+ }
break;
}
}
}
```
case 'P2002': {
const status = HttpStatus.CONFLICT;
response.status(status).json({
statusCode: status,
message: 'A record with this value already exists.',
});
break;
}
🧰 Tools
🪛 LanguageTool

[style] ~284-~284: ‘many different kinds of’ might be wordy. Consider a shorter alternative.
Context: ...the PrismaClientKnownRequestError for many different kinds of errors. So you will need to figure out ...

(EN_WORDINESS_PREMIUM_MANY_DIFFERENT_KINDS_OF)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/blog/content/blog/nestjs-prisma-error-handling-7D056s1kOop2/index.mdx`
around lines 255 - 323, The P2002 branch in PrismaClientExceptionFilter is
exposing raw Prisma error details to clients. Update the catch method so it
still logs exception.message server-side, but returns a generic conflict
response for the P2002 case instead of using the raw exception.message in the
JSON payload. Keep the existing switch on exception.code in
PrismaClientExceptionFilter and adjust the response.status(...).json(...)
payload to use a user-friendly message while preserving the default super.catch
fallback for other Prisma errors.


![`GET /articles/:id` reveals password](/nestjs-prisma-relational-data-7D056s1kOabc/imgs/password-revealed-get-articles.png)

The reason for this issue is very similar to last time. Currently, the `ArticlesController` returns instances of Prisma generated types, whereas the `ClassSerializerInterceptor` works with the `UserEntity` class. To fix this, you will update the implementation of the `ArticleEntity` class and make sure it initializes the `author` property with an instance of `UserEntity`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a hyphen to "Prisma-generated types".

"Prisma generated types" is a compound adjective modifying "types" and should be hyphenated.

✏️ Proposed grammar fix
-Currently, the `ArticlesController` returns instances of Prisma generated types, whereas the `ClassSerializerInterceptor` works with the `UserEntity` class.
+Currently, the `ArticlesController` returns instances of Prisma-generated types, whereas the `ClassSerializerInterceptor` works with the `UserEntity` class.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The reason for this issue is very similar to last time. Currently, the `ArticlesController` returns instances of Prisma generated types, whereas the `ClassSerializerInterceptor` works with the `UserEntity` class. To fix this, you will update the implementation of the `ArticleEntity` class and make sure it initializes the `author` property with an instance of `UserEntity`.
The reason for this issue is very similar to last time. Currently, the `ArticlesController` returns instances of Prisma-generated types, whereas the `ClassSerializerInterceptor` works with the `UserEntity` class. To fix this, you will update the implementation of the `ArticleEntity` class and make sure it initializes the `author` property with an instance of `UserEntity`.
🧰 Tools
🪛 LanguageTool

[grammar] ~790-~790: Use a hyphen to join words.
Context: ...sControllerreturns instances of Prisma generated types, whereas theClassSeria...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/blog/content/blog/nestjs-prisma-relational-data-7D056s1kOabc/index.mdx`
at line 790, Update the wording in the affected prose to hyphenate the compound
adjective “Prisma-generated types” instead of “Prisma generated types.” Locate
the sentence discussing ArticlesController, ArticleEntity, and
ClassSerializerInterceptor, and make the small text-only grammar correction
without changing any technical meaning.

Source: Linters/SAST tools

To follow along with this tutorial, you will be expected to have:
To follow along with this tutorial, you will be expected to:

- ... have [Node.js](https://nodejs.org) (v18 or higher) installed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What is the minimum Node.js version required for NestJS 11?

💡 Result:

The minimum Node.js version required for NestJS 11 is Node.js v20 [1][2][3][4]. Starting with version 11, support for Node.js v16 and v18 was dropped, making v20 the mandatory floor for the framework [1][2][3]. Official documentation recommends using the latest LTS (Long Term Support) version of Node.js to ensure the best experience and performance [1][2].

Citations:


Update the Node.js requirement to v20+

NestJS 11 drops Node 18 support, so “v18 or higher” is misleading here. This tutorial should require Node.js 20 or newer to match the stack.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/blog/content/blog/nestjs-prisma-validation-7D056s1kOla1/index.mdx` at
line 39, The Node.js prerequisite in the tutorial is outdated and should be
raised to match the stack. Update the requirement text in the blog content to
specify Node.js v20 or higher instead of v18 or higher, and keep the wording
consistent with the setup instructions in this article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants