Skip to content

Conversation

mhartington
Copy link
Contributor

@mhartington mhartington commented Oct 3, 2025

Summary by CodeRabbit

  • Documentation
    • Added a new guide: “How to use Prisma ORM with Hono” — a step-by-step walkthrough for integrating Prisma with Postgres in a Hono backend, covering setup, schema/client generation, seeding, env configuration, example routes, dev workflow, and next steps. Includes code examples, tabbed comparisons, and both Accelerate and non‑Accelerate per-request client middleware patterns.
    • Updated navigation to list the new guide under Guides > Web Frameworks.

Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Adds a new Hono + Prisma guide at content/800-guides/390-hono.mdx and registers it in sidebars.ts under Guides > Web Frameworks. The guide covers prerequisites, Hono setup, Prisma Postgres schema, client generation, dotenv, seeding, TypeScript context augmentation, middleware patterns (with and without Accelerate), and example routes.

Changes

Cohort / File(s) Summary
Guide: Hono + Prisma
content/800-guides/390-hono.mdx
New MDX guide showing Hono project setup, Prisma Postgres schema, Prisma Client generation, dotenv env loading, seeding scripts, TypeScript augmentation for Hono context, per-request Prisma middleware (Accelerate and non-Accelerate), example GET route(s), and DB comparison tabs. Includes TS, Prisma schema, JSON, and shell snippets.
Sidebar Registration
sidebars.ts
Adds the new guide ID ("guides/hono") into the Guides > Web Frameworks array (array is later sorted). No other logic changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as HTTP Client
  participant Hono as Hono App
  participant Middleware as Prisma Middleware
  participant Prisma as PrismaClient
  participant Handler as Route Handler

  Client->>Hono: HTTP request
  Hono->>Middleware: invoke per-request middleware
  Middleware->>Prisma: initialize/expose client (withAccelerate or plain)
  Middleware-->>Hono: attach `prisma` to ctx
  Hono->>Handler: call route handler (ctx.prisma available)
  Handler->>Prisma: run query (e.g., findMany users)
  Prisma-->>Handler: return results
  Handler-->>Client: HTTP response

  note right of Middleware #DDDDFF: Middleware may instantiate per-request\nor attach an Accelerate-enabled client extension
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • mhessdev
  • nikolasburk

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly identifies the primary purpose of the changeset—creating the Hono guide—and references the associated ticket, making it directly related to the new MDX guide addition without using vague language. It is concise and specific enough for a teammate to understand the main update at a glance.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mhartington/DA-5233-hono-guide

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7856781 and 9649338.

📒 Files selected for processing (1)
  • content/800-guides/390-hono.mdx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • content/800-guides/390-hono.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: runner / linkspector

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 and usage tips.

Copy link
Contributor

github-actions bot commented Oct 3, 2025

Dangerous URL check

No absolute URLs to prisma.io/docs found.
No local URLs found.

Copy link
Contributor

github-actions bot commented Oct 3, 2025

Copy link
Contributor

github-actions bot commented Oct 3, 2025

Redirect check

This PR probably requires the following redirects to be added to static/_redirects:

  • This PR does not change any pages in a way that would require a redirect.

Copy link

cloudflare-workers-and-pages bot commented Oct 3, 2025

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2cc25c3
Status: ✅  Deploy successful!
Preview URL: https://0f7b1599.docs-51g.pages.dev
Branch Preview URL: https://mhartington-da-5233-hono-gui.docs-51g.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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)
content/800-guides/390-hono.mdx (1)

232-246: Consider adding PrismaClient cleanup to prevent connection leaks.

The middleware creates a PrismaClient and stores it in the context, but there's no cleanup logic to disconnect the client after the request completes. This could lead to connection exhaustion over time.

Consider adding a cleanup mechanism or documenting the connection lifecycle. One approach is to use Hono's context cleanup or ensure the client is short-lived:

 function withPrisma(c: Context, next: Next) {
   if (!c.get('prisma')) {
     const databaseUrl = process.env.DATABASE_URL;

     if (!databaseUrl) {
       throw new Error('DATABASE_URL is not set');
     }
     const prisma = new PrismaClient({ datasourceUrl: databaseUrl })
     .$extends( withAccelerate(),);

     c.set('prisma', prisma);
   }
-  return next();
+  return next().finally(() => {
+    // Optionally disconnect after request
+    // const prisma = c.get('prisma');
+    // await prisma.$disconnect();
+  });
 }

Note: With Prisma Accelerate, connection pooling is handled externally, so this may be less critical. However, it's worth documenting the expected behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09ceaf5 and 7397e67.

📒 Files selected for processing (2)
  • content/800-guides/390-hono.mdx (1 hunks)
  • sidebars.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: runner / linkspector
  • GitHub Check: Check internal links
  • GitHub Check: Lost Pixel
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
sidebars.ts (1)

421-421: LGTM!

The addition of "guides/hono" to the Web Frameworks list is correct and follows the existing pattern. The .sort() call ensures proper alphabetical ordering in the sidebar.

content/800-guides/390-hono.mdx (5)

74-103: LGTM!

The Prisma schema definition is well-structured with a clear one-to-many relationship between User and Post models. The generator configuration correctly sets the output path.


286-293: LGTM!

The dotenv setup is correctly implemented and the explanation is clear about why it's needed for Hono.


298-308: LGTM!

The type augmentation for Hono context is properly implemented, ensuring type safety when accessing the Prisma client from the context.


321-330: LGTM!

The GET route example is well-structured and demonstrates proper usage of the Prisma client from Hono's context, including related data with the include option.


60-60: No change needed for Prisma output path
The --output ../src/generated/prisma flag correctly points from prisma/schema.prisma to the src/generated/prisma directory in a standard Hono project setup.

@mhartington mhartington marked this pull request as draft October 3, 2025 17:20
@mhartington mhartington force-pushed the mhartington/DA-5233-hono-guide branch 3 times, most recently from 7734bf4 to 6d0445a Compare October 6, 2025 13:59
Copy link
Contributor

github-actions bot commented Oct 6, 2025

Images automagically compressed by Calibre's image-actions

Compression reduced images by 85.9%, saving 334.7 KB.

Filename Before After Improvement Visual comparison
static/img/guides/prisma-hono-cover.png 389.7 KB 55.0 KB 85.9% View diff

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 6, 2025
@mhartington mhartington marked this pull request as ready for review October 6, 2025 14:03
@mhartington mhartington force-pushed the mhartington/DA-5233-hono-guide branch from 332533a to d4d2460 Compare October 6, 2025 14:10
Copy link
Contributor

github-actions bot commented Oct 6, 2025

Images automagically compressed by Calibre's image-actions

Compression reduced images by 10.3%, saving 5.7 KB.

Filename Before After Improvement Visual comparison
static/img/guides/prisma-hono-cover.png 55.0 KB 49.3 KB 10.3% View diff

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 332533a and 4fc3273.

⛔ Files ignored due to path filters (1)
  • static/img/guides/prisma-hono-cover.png is excluded by !**/*.png
📒 Files selected for processing (2)
  • content/800-guides/390-hono.mdx (1 hunks)
  • sidebars.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • sidebars.ts
🔇 Additional comments (4)
content/800-guides/390-hono.mdx (4)

28-34: Verify Hono CLI prompts.

Two install prompts look duplicated. Please confirm the current npm create hono@latest questions and update this list accordingly.


74-80: Confirm generator settings match the pinned Prisma versions.

provider = "prisma-client" and engineType = "client" may be version‑specific. Ensure these are valid for @prisma/client and prisma versions specified.


15-16: Validate example link points to a Hono app.

The example repo path looks generic (Node). Confirm it matches Hono or link to a Hono‑specific example if available.


6-6: Cover image verified
The file /img/guides/prisma-hono-cover.png exists.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 6, 2025
Co-authored-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com>
Co-authored-by: Aidan McAlister <105178005+aidankmcalister@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
content/800-guides/390-hono.mdx (2)

272-288: Tighten the wording in the environment/type section.

Fix the lingering typos/grammar (“will be read that file…”, “to to know”) for clarity and polish. Example rewrite: “dotenv reads that file and exposes the values via process.env. Next, add types so Hono knows the withPrisma middleware sets a prisma key on the context.”


346-355: Clean up the wording around running the dev script.

“Start the Hono app by call…” should be “by calling,” and the following sentence can be tightened (“You should see ‘Server is running…’”). This keeps the prose consistent with the rest of the guide.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d51e0d0 and 7856781.

📒 Files selected for processing (1)
  • content/800-guides/390-hono.mdx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: runner / linkspector

Co-authored-by: Aidan McAlister <105178005+aidankmcalister@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 6, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 6, 2025
@mhartington mhartington merged commit b6ce76f into main Oct 10, 2025
10 of 13 checks passed
@mhartington mhartington deleted the mhartington/DA-5233-hono-guide branch October 10, 2025 13:36
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.

4 participants