Skip to content

Commit

Permalink
refactor docs (#86)
Browse files Browse the repository at this point in the history
* refactor docs imports for clarity and completeness

* refactor exception filter docs separating code block logic into two distinct examples
  • Loading branch information
gonza7aav authored Nov 27, 2023
1 parent a8f2ba5 commit 2e9594d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/src/content/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Alternatively, you can use a class instead of a factory:

```ts
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { PrismaModule } from 'nestjs-prisma';

@Module({
Expand Down
21 changes: 16 additions & 5 deletions docs/src/content/docs/exception-filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Instantiate the filter in your `main.ts` and pass the `HttpAdapterHost`

```ts
//src/main.ts
import { ValidationPipe } from '@nestjs/common';
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { PrismaClientExceptionFilter } from 'nestjs-prisma';
Expand Down Expand Up @@ -67,7 +66,6 @@ Or use `providePrismaClientExceptionFilter()` (available since `v0.21.0-dev.0`)
```ts
//src/app.module.ts
import { Module } from '@nestjs/common';
import { APP_FILTER, HttpAdapterHost } from '@nestjs/core';
import { providePrismaClientExceptionFilter } from 'nestjs-prisma';

@Module({
Expand All @@ -84,7 +82,7 @@ Provide your own error code mapping, if you like to catch additional [Prisma Cli

```ts
//src/main.ts
import { ValidationPipe } from '@nestjs/common';
import { HttpStatus } from '@nestjs/common';
import { HttpAdapterHost, NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { PrismaClientExceptionFilter } from 'nestjs-prisma';
Expand All @@ -111,7 +109,7 @@ bootstrap();

```ts
//src/app.module.ts
import { Module } from '@nestjs/common';
import { HttpStatus, Module } from '@nestjs/common';
import { APP_FILTER, HttpAdapterHost } from '@nestjs/core';
import { PrismaClientExceptionFilter } from 'nestjs-prisma';

Expand All @@ -129,7 +127,20 @@ import { PrismaClientExceptionFilter } from 'nestjs-prisma';
},
inject: [HttpAdapterHost],
},
// or
],
})
export class AppModule {}
```

Or use `providePrismaClientExceptionFilter()` (available since `v0.21.0-dev.0`)

```ts
//src/app.module.ts
import { HttpStatus, Module } from '@nestjs/common';
import { providePrismaClientExceptionFilter } from 'nestjs-prisma';

@Module({
providers: [
providePrismaClientExceptionFilter({
// Prisma Error Code: HTTP Status Response
P2000: HttpStatus.BAD_REQUEST,
Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/logging-middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Change the log level from your `.env` file using the [@nestjs/config](https://do

```ts
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { PrismaModule, loggingMiddleware, QueryInfo } from 'nestjs-prisma';

@Module({
Expand Down

0 comments on commit 2e9594d

Please sign in to comment.