Skip to content

Commit 8bddb4e

Browse files
authored
Merge pull request #37 from Fecony/patch-3
Update with-prisma.md
2 parents 9befc0f + 70947e1 commit 8bddb4e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

docs/blog/with-prisma.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ And then just add the plugin:
350350
```ts
351351
import { Elysia, t } from 'elysia'
352352
import { PrismaClient } from '@prisma/client'
353-
import { swagger } from '@elysiajs/swagger'
353+
import { swagger } from '@elysiajs/swagger' // [!code ++]
354354
355355
const db = new PrismaClient()
356356

357357
const app = new Elysia()
358-
.use(swagger())
358+
.use(swagger()) // [!code ++]
359359
.post(
360360
'/',
361361
async ({ body }) =>
@@ -368,8 +368,6 @@ const app = new Elysia()
368368
}),
369369
{
370370
error({ code }) {
371-
console.log(code)
372-
373371
switch (code) {
374372
// Prisma P2002: "Unique constraint failed on the {constraint}"
375373
case 'P2002':
@@ -401,7 +399,7 @@ And that's all it takes to create a well-defined documentation for our API.
401399

402400
<img class="-png" src="/blog/with-prisma/swagger.webp" alt="Swagger documentation generated by Elysia" />
403401

404-
And thanks to defining a strict type for the documentation, we found that we accidentally returns `password` field from our API which is not a good idea to return a private information.
402+
And thanks to defining a strict type for the documentation, we found that we accidentally return `password` field from our API which is not a good idea to return a private information.
405403

406404
Thanks to Elysia's type system, we define that response shouldn't contains `password` which automatically warn us that our Prisma query are returning a password allows us to fix that a head of time.
407405

0 commit comments

Comments
 (0)