-
Notifications
You must be signed in to change notification settings - Fork 852
DA-5233 Hono Guide Created #7156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a new Hono + Prisma guide at 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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. Comment |
Dangerous URL checkNo absolute URLs to prisma.io/docs found. |
|
Redirect checkThis PR probably requires the following redirects to be added to static/_redirects:
|
Deploying docs with
|
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 |
There was a problem hiding this 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
📒 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
andPost
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 fromprisma/schema.prisma
to thesrc/generated/prisma
directory in a standard Hono project setup.
7734bf4
to
6d0445a
Compare
Images automagically compressed by Calibre's image-actions ✨ Compression reduced images by 85.9%, saving 334.7 KB.
|
332533a
to
d4d2460
Compare
Images automagically compressed by Calibre's image-actions ✨ Compression reduced images by 10.3%, saving 5.7 KB.
|
There was a problem hiding this 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
⛔ 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"
andengineType = "client"
may be version‑specific. Ensure these are valid for@prisma/client
andprisma
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>
Co-authored-by: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Co-authored-by: Aidan McAlister <105178005+aidankmcalister@users.noreply.github.com>
There was a problem hiding this 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 viaprocess.env
. Next, add types so Hono knows thewithPrisma
middleware sets aprisma
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
📒 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>
Summary by CodeRabbit