Skip to content

Conversation

@nikolasburk
Copy link
Contributor

@nikolasburk nikolasburk commented Oct 14, 2025

Summary by CodeRabbit

  • New Features

    • Environment variables now load automatically at startup for simpler configuration.
  • Chores

    • Upgraded Prisma and related tooling to newer versions.
    • Switched development runner from ts-node to tsx and updated scripts.
    • Added dotenv as a runtime dependency and updated seeding invocation.
    • Added Prisma accelerate extension dependency.
  • Refactor

    • Switched to a locally generated Prisma client and changed its generation output path.

@coderabbitai
Copy link

coderabbitai bot commented Oct 14, 2025

Walkthrough

Switches Prisma generator to emit a local client and updates code to import that generated client. Adds dotenv initialization and replaces ts-node with tsx for dev/seed scripts. Bumps Prisma packages, adds dotenv and tsx, and updates imports across express, fastify, hapi, koa, and nest. No schema models or datasource changes.

Changes

Cohort / File(s) Summary
Tooling & scripts — package.json (frameworks)
orm/express/package.json, orm/fastify/package.json, orm/hapi/package.json, orm/koa/package.json, orm/nest/package.json
Replace ts-node with tsx in dev and prisma:seed scripts; add dotenv dependency; add tsx devDependency; bump @prisma/client and prisma to 6.17.1; add/retain @prisma/extension-accelerate where present.
Prisma generator config — schemas
orm/.../prisma/schema.prisma (express, fastify, hapi, koa, nest)
Change generator provider from "prisma-client-js" to "prisma-client"; add engineType = "client" and output = "../src/generated/prisma".
Generated-client imports — app entry points & plugins
orm/express/src/index.ts, orm/fastify/src/index.ts, orm/koa/src/index.ts, orm/hapi/src/plugins/prisma.ts, orm/nest/src/app.controller.ts
Replace imports from @prisma/client with local generated client path (./generated/prisma/client or ../generated/prisma/client); add dotenv side-effect/import (dotenv/config or dotenv.config() where applicable).
Seed files — prisma seeds
orm/express/prisma/seed.ts, orm/fastify/prisma/seed.ts, orm/hapi/prisma/seed.ts, orm/koa/prisma/seed.ts, orm/nest/prisma/seed.ts
Update imports to use generated local client (../src/generated/prisma/client); add dotenv side-effect import in some seeds; seed logic unchanged.
Hapi plugins — small edits
orm/hapi/src/plugins/users.ts, orm/hapi/src/plugins/posts.ts
Update Prisma type imports to the generated client path; remove an unused commented import in posts.ts.
Docs / examples
orm/nest/README.md
Update example imports to reference ./generated/prisma/client instead of @prisma/client.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Node as Node process
  participant Env as dotenv
  participant App as App entry (index.ts / plugin)
  participant GC as Generated Prisma Client
  participant DB as Database

  Note over Node,Env: startup
  Node->>Env: import dotenv / config()
  Env-->>Node: process.env populated

  Node->>App: run entry (index.ts / plugin)
  App->>GC: import & instantiate PrismaClient (from ./generated/prisma/client)
  GC->>DB: connect / queries
  DB-->>GC: responses
  GC-->>App: data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title "update express.js project" references only the Express example but the pull request updates multiple ORM examples across Express, Fastify, Hapi, Koa, and Nest and does not accurately summarize the scope. Revise the title to concisely reflect the broad set of updates, such as "Update ORM examples (Express, Fastify, Hapi, Koa, Nest) to use Prisma HTTP v7 configuration."
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

Copy link

@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: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5206f and 3737af4.

⛔ Files ignored due to path filters (10)
  • orm/express/src/generated/prisma/browser.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/client.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/commonInputTypes.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/enums.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/internal/class.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/internal/prismaNamespace.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/internal/prismaNamespaceBrowser.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/models.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/models/Post.ts is excluded by !**/generated/**
  • orm/express/src/generated/prisma/models/User.ts is excluded by !**/generated/**
📒 Files selected for processing (4)
  • orm/express/package.json (1 hunks)
  • orm/express/prisma/schema.prisma (1 hunks)
  • orm/express/prisma/seed.ts (1 hunks)
  • orm/express/src/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: FGoessler
PR: prisma/prisma-examples#8260
File: generator-prisma-client/nextjs-starter-webpack-turborepo/packages/database/package.json:13-13
Timestamp: 2025-08-22T12:12:24.602Z
Learning: When analyzing changes from package.json seed scripts to "prisma db seed", always verify the actual content of prisma.config.ts rather than relying solely on regex patterns, as the configuration may be properly defined but in a format that doesn't match overly restrictive search patterns.
📚 Learning: 2025-08-22T12:12:24.602Z
Learnt from: FGoessler
PR: prisma/prisma-examples#8260
File: generator-prisma-client/nextjs-starter-webpack-turborepo/packages/database/package.json:13-13
Timestamp: 2025-08-22T12:12:24.602Z
Learning: When analyzing changes from package.json seed scripts to "prisma db seed", always verify the actual content of prisma.config.ts rather than relying solely on regex patterns, as the configuration may be properly defined but in a format that doesn't match overly restrictive search patterns.

Applied to files:

  • orm/express/package.json
  • orm/express/prisma/seed.ts
⏰ 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). (6)
  • GitHub Check: test (orm/nest)
  • GitHub Check: test (orm/grpc)
  • GitHub Check: test (orm/nest-graphql-sdl-first)
  • GitHub Check: test (orm/nest-graphql)
  • GitHub Check: test (orm/nuxt)
  • GitHub Check: test (orm/solid-start)
🔇 Additional comments (8)
orm/express/src/index.ts (2)

1-1: Import path change to locally generated client.

The import has been updated to use the locally generated Prisma client at ./generated/prisma/client. This aligns with the generator configuration in schema.prisma that outputs to ../src/generated/prisma.

Verify that the path resolves correctly: from src/index.ts, the import ./generated/prisma/client should find the generated client at src/generated/prisma/client.


4-6: LGTM: dotenv initialization correctly placed; README documents .env creation for DATABASE_URL

orm/express/package.json (4)

6-6: LGTM: Modern tsx replacing ts-node for development.

The switch from ts-node to tsx for the dev script is a good modernization choice. tsx is faster and has better ESM support.


11-11: LGTM: dotenv dependency added.

The dotenv package at version ^17.2.3 has been added, which is the latest stable version. This aligns with the dotenv initialization added in src/index.ts.

Based on learnings.


18-18: LGTM: tsx added as modern TypeScript executor.

The tsx package (^4.20.6) replaces ts-node for both development and seeding scripts, providing faster execution and better module resolution.


22-22: LGTM: Seed script updated to use tsx.

The seed script has been consistently updated to use tsx instead of ts-node, matching the dev script change.

orm/express/prisma/seed.ts (1)

1-1: LGTM: Import path updated to locally generated client.

The import has been correctly updated from @prisma/client to ../src/generated/prisma/client, which resolves from prisma/seed.ts to the generated client at src/generated/prisma/client. This change is consistent with the generator configuration in schema.prisma and the import in src/index.ts.

The seeding logic remains unchanged and will continue to work with the locally generated client.

orm/express/prisma/schema.prisma (1)

2-4: Prisma generator configuration is valid

  • provider "prisma-client" and engineType = "client" are supported in Prisma v6.17.1.
  • src/generated/prisma/ is correctly excluded in .gitignore.
  • update your migration guide to document these generator changes.

},
"dependencies": {
"@prisma/client": "6.9.0",
"@prisma/client": "6.17.1",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify Prisma version 6.17.1 is the latest.

Both @prisma/client and prisma have been updated to version 6.17.1. Please confirm this is the latest stable version or if it's intentionally pinned to this specific version.

Also applies to: 17-17


🌐 Web query:

What is the latest stable version of Prisma (prisma and @prisma/client packages) as of October 2025?

💡 Result:

As of October 14, 2025:

  • @prisma/client — 6.15.0. [1]
  • prisma — 6.14.0. [2]

Sources:
[1] npm: @prisma/client package page.
[2] npm: prisma package page.


Pin @prisma/client to an available version
@prisma/client@6.17.1 isn’t published on npm (latest stable is 6.15.0; prisma is 6.14.0). Update to a released version or justify the intentional 6.17.1 pin.

🤖 Prompt for AI Agents
In orm/express/package.json at line 9, @prisma/client is pinned to 6.17.1 which
is not published; change the dependency to a released version (e.g., "6.15.0")
or to the exact version that matches the published prisma package, update
package-lock.json by running npm install (or pnpm/yarn equivalent), and if the
6.17.1 pin is intentional add a comment in the PR or package.json documentation
justifying it and include steps to obtain that version (e.g., private registry
or nightly build).

Copy link

@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: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3737af4 and d3a2d11.

📒 Files selected for processing (4)
  • orm/fastify/package.json (1 hunks)
  • orm/fastify/prisma/schema.prisma (1 hunks)
  • orm/fastify/prisma/seed.ts (1 hunks)
  • orm/fastify/src/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-22T12:12:24.602Z
Learnt from: FGoessler
PR: prisma/prisma-examples#8260
File: generator-prisma-client/nextjs-starter-webpack-turborepo/packages/database/package.json:13-13
Timestamp: 2025-08-22T12:12:24.602Z
Learning: When analyzing changes from package.json seed scripts to "prisma db seed", always verify the actual content of prisma.config.ts rather than relying solely on regex patterns, as the configuration may be properly defined but in a format that doesn't match overly restrictive search patterns.

Applied to files:

  • orm/fastify/package.json
  • orm/fastify/prisma/seed.ts
⏰ 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: test (orm/grpc)
  • GitHub Check: test (orm/nest)
  • GitHub Check: test (orm/nest-graphql)
  • GitHub Check: test (orm/nuxt)
🔇 Additional comments (4)
orm/fastify/prisma/seed.ts (1)

1-3: LGTM! Import changes align with the local client generation.

The updated imports correctly reference the locally generated Prisma client and add environment variable loading. The path ../src/generated/prisma/client is correct relative to this seed file's location.

orm/fastify/package.json (2)

6-6: LGTM! Modern script runner.

Replacing ts-node with tsx is a good modernization choice for faster TypeScript execution.


20-20: LGTM! Seed script updated consistently.

The seed script now uses tsx instead of ts-node, consistent with the dev script change.

orm/fastify/prisma/schema.prisma (1)

2-4: Prisma generator configuration is valid.
provider = "prisma-client" and engineType = "client" are supported since v6.16.0; no changes required.

Comment on lines 8 to 17
"dependencies": {
"@prisma/client": "6.9.0",
"fastify": "5.6.1",
"@prisma/extension-accelerate": "2.0.2"
"@prisma/client": "6.17.1",
"@prisma/extension-accelerate": "2.0.2",
"fastify": "5.6.1"
},
"devDependencies": {
"@types/node": "22.15.32",
"prisma": "6.9.0",
"ts-node": "10.9.2",
"prisma": "6.17.1",
"tsx": "^4.20.6",
"typescript": "5.8.2"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Add missing dotenv dependency.

The code imports dotenv/config in both src/index.ts and prisma/seed.ts, but the dotenv package is not listed in dependencies or devDependencies. This will cause runtime errors.

Add dotenv to your dependencies:

  "dependencies": {
    "@prisma/client": "6.17.1",
    "@prisma/extension-accelerate": "2.0.2",
+   "dotenv": "^16.4.7",
    "fastify": "5.6.1"
  },
📝 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
"dependencies": {
"@prisma/client": "6.9.0",
"fastify": "5.6.1",
"@prisma/extension-accelerate": "2.0.2"
"@prisma/client": "6.17.1",
"@prisma/extension-accelerate": "2.0.2",
"fastify": "5.6.1"
},
"devDependencies": {
"@types/node": "22.15.32",
"prisma": "6.9.0",
"ts-node": "10.9.2",
"prisma": "6.17.1",
"tsx": "^4.20.6",
"typescript": "5.8.2"
"dependencies": {
"@prisma/client": "6.17.1",
"@prisma/extension-accelerate": "2.0.2",
"dotenv": "^16.4.7",
"fastify": "5.6.1"
},
🤖 Prompt for AI Agents
In orm/fastify/package.json around lines 8 to 17, the project imports
dotenv/config at runtime but dotenv is not listed in package.json; add dotenv to
the "dependencies" section (not devDependencies) and install it (update
lockfile) so runtime imports succeed—e.g., add dotenv to dependencies and run
the package manager install command to persist the change.

Comment on lines +1 to +4
import { Prisma, PrismaClient } from './generated/prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

import fastify from 'fastify'
import 'dotenv/config'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify dotenv dependency availability.

The import changes look correct, with the locally generated client path matching the schema output configuration. However, dotenv/config is imported but dotenv doesn't appear in the package.json dependencies.

Run this script to verify dotenv is available:


🏁 Script executed:

#!/bin/bash
# Check if dotenv is a dependency or peer dependency of any installed package
cat orm/fastify/package.json | jq '.dependencies, .devDependencies'

# Check if dotenv/config is accessible from node_modules
fd -t f "config.js" node_modules/dotenv 2>/dev/null || echo "dotenv not found in node_modules"

Length of output: 229


Add missing dotenv dependency

import 'dotenv/config' will fail at runtime since dotenv isn’t installed. Add it to dependencies in orm/fastify/package.json.

🤖 Prompt for AI Agents
In orm/fastify/src/index.ts lines 1-4 the runtime import 'dotenv/config' will
fail because dotenv is not listed in package.json; open orm/fastify/package.json
and add dotenv to the "dependencies" (not devDependencies), then run your
package manager to install it (e.g., npm install --save dotenv or yarn add
dotenv) so the import succeeds at runtime.

Copy link

@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: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3a2d11 and 03c6844.

⛔ Files ignored due to path filters (20)
  • orm/fastify/src/generated/prisma/browser.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/client.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/commonInputTypes.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/enums.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/internal/class.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/internal/prismaNamespace.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/internal/prismaNamespaceBrowser.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/models.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/models/Post.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/models/User.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/browser.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/client.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/commonInputTypes.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/enums.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/internal/class.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/internal/prismaNamespace.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/internal/prismaNamespaceBrowser.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/models.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/models/Post.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/models/User.ts is excluded by !**/generated/**
📒 Files selected for processing (6)
  • orm/hapi/package.json (1 hunks)
  • orm/hapi/prisma/schema.prisma (1 hunks)
  • orm/hapi/prisma/seed.ts (1 hunks)
  • orm/hapi/src/plugins/posts.ts (0 hunks)
  • orm/hapi/src/plugins/prisma.ts (1 hunks)
  • orm/hapi/src/plugins/users.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • orm/hapi/src/plugins/posts.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-22T12:12:24.602Z
Learnt from: FGoessler
PR: prisma/prisma-examples#8260
File: generator-prisma-client/nextjs-starter-webpack-turborepo/packages/database/package.json:13-13
Timestamp: 2025-08-22T12:12:24.602Z
Learning: When analyzing changes from package.json seed scripts to "prisma db seed", always verify the actual content of prisma.config.ts rather than relying solely on regex patterns, as the configuration may be properly defined but in a format that doesn't match overly restrictive search patterns.

Applied to files:

  • orm/hapi/package.json
  • orm/hapi/prisma/seed.ts
⏰ 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: test (orm/grpc)
  • GitHub Check: test (orm/nest-graphql)
  • GitHub Check: test (orm/nest)
  • GitHub Check: test (orm/nest-graphql-sdl-first)
🔇 Additional comments (5)
orm/hapi/package.json (2)

10-11: LGTM! Prisma dependency updates are correct.

The Prisma packages are correctly updated to version 6.17.1 (latest patch release as of October 2025) and all versions are aligned, which follows best practices for avoiding version mismatches between prisma and @prisma/client.

Based on learnings.

Also applies to: 19-20


6-6: LGTM! tsx replacement is appropriate.

Replacing ts-node with tsx for the dev and seed scripts is a solid improvement—tsx provides faster TypeScript execution and better ESM support.

Also applies to: 24-24

orm/hapi/src/plugins/users.ts (1)

2-2: LGTM! Import path correctly updated.

The import path is accurately adjusted to reference the locally generated Prisma client at ../generated/prisma/client, which aligns with the generator output configuration in schema.prisma.

orm/hapi/src/plugins/prisma.ts (1)

1-1: LGTM! Prisma client path and environment loading correctly configured.

The import path for the generated Prisma client is correct, and dotenv/config is properly imported at the module level to ensure environment variables are loaded before the PrismaClient singleton is created.

Also applies to: 4-4

orm/hapi/prisma/schema.prisma (1)

2-4: Approve updated Prisma generator configuration.

provider = "prisma-client", engineType = "client", and the custom output path are valid and recommended in Prisma 6.17.1. No changes required.

Comment on lines +1 to 4
import { PrismaClient, Prisma } from '../src/generated/prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient().$extends(withAccelerate())
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verify that environment variables are loaded for the seed script.

The seed script instantiates PrismaClient directly, which requires DATABASE_URL from environment variables. However, this file doesn't import dotenv/config to load the .env file. While tsx may auto-load .env in some configurations, explicitly importing dotenv/config ensures the seed script works reliably.

Consider adding dotenv/config import at the top of this file for explicit environment variable loading:

+import 'dotenv/config'
 import { PrismaClient, Prisma } from '../src/generated/prisma/client'
 import { withAccelerate } from '@prisma/extension-accelerate'

Run this script to check if there are any environment loading mechanisms in the seed script or tsx configuration:


🏁 Script executed:

#!/bin/bash
# Description: Check if tsx or other mechanisms handle .env loading automatically

# Check if there's a tsx config that might load .env
fd -t f "tsx.config|tsconfig.json" orm/hapi

# Check if there are any other dotenv imports or .env loading in the project
rg -t ts "dotenv" orm/hapi --no-heading -C 2

Length of output: 329


Import dotenv/config in seed.ts to ensure DATABASE_URL is loaded
The seed script directly instantiates PrismaClient without loading environment variables. Add at the top of orm/hapi/prisma/seed.ts:

+import 'dotenv/config'
 import { PrismaClient, Prisma } from '../src/generated/prisma/client'
 import { withAccelerate } from '@prisma/extension-accelerate'
📝 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
import { PrismaClient, Prisma } from '../src/generated/prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'
const prisma = new PrismaClient().$extends(withAccelerate())
import 'dotenv/config'
import { PrismaClient, Prisma } from '../src/generated/prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'
const prisma = new PrismaClient().$extends(withAccelerate())
🤖 Prompt for AI Agents
In orm/hapi/prisma/seed.ts around lines 1 to 4, the seed script instantiates
PrismaClient before environment variables (like DATABASE_URL) are loaded; add a
top-level import of dotenv (e.g. import 'dotenv/config' or call
require('dotenv').config() before any PrismaClient usage) so the environment is
loaded prior to creating the PrismaClient instance, then keep the existing
imports and instantiation as-is.

Copy link

@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: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3a2d11 and 920131d.

⛔ Files ignored due to path filters (30)
  • orm/fastify/src/generated/prisma/browser.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/client.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/commonInputTypes.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/enums.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/internal/class.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/internal/prismaNamespace.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/internal/prismaNamespaceBrowser.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/models.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/models/Post.ts is excluded by !**/generated/**
  • orm/fastify/src/generated/prisma/models/User.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/browser.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/client.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/commonInputTypes.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/enums.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/internal/class.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/internal/prismaNamespace.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/internal/prismaNamespaceBrowser.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/models.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/models/Post.ts is excluded by !**/generated/**
  • orm/hapi/src/generated/prisma/models/User.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/browser.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/client.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/commonInputTypes.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/enums.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/internal/class.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/internal/prismaNamespace.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/internal/prismaNamespaceBrowser.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/models.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/models/Post.ts is excluded by !**/generated/**
  • orm/koa/src/generated/prisma/models/User.ts is excluded by !**/generated/**
📒 Files selected for processing (10)
  • orm/hapi/package.json (1 hunks)
  • orm/hapi/prisma/schema.prisma (1 hunks)
  • orm/hapi/prisma/seed.ts (1 hunks)
  • orm/hapi/src/plugins/posts.ts (0 hunks)
  • orm/hapi/src/plugins/prisma.ts (1 hunks)
  • orm/hapi/src/plugins/users.ts (1 hunks)
  • orm/koa/package.json (1 hunks)
  • orm/koa/prisma/schema.prisma (1 hunks)
  • orm/koa/prisma/seed.ts (1 hunks)
  • orm/koa/src/index.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • orm/hapi/src/plugins/posts.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-22T12:12:24.602Z
Learnt from: FGoessler
PR: prisma/prisma-examples#8260
File: generator-prisma-client/nextjs-starter-webpack-turborepo/packages/database/package.json:13-13
Timestamp: 2025-08-22T12:12:24.602Z
Learning: When analyzing changes from package.json seed scripts to "prisma db seed", always verify the actual content of prisma.config.ts rather than relying solely on regex patterns, as the configuration may be properly defined but in a format that doesn't match overly restrictive search patterns.

Applied to files:

  • orm/hapi/prisma/seed.ts
  • orm/koa/prisma/seed.ts
  • orm/hapi/package.json
⏰ 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). (5)
  • GitHub Check: test (orm/nest-graphql-sdl-first)
  • GitHub Check: test (orm/grpc)
  • GitHub Check: test (orm/nuxt)
  • GitHub Check: test (orm/nest)
  • GitHub Check: test (orm/nest-graphql)
🔇 Additional comments (12)
orm/hapi/package.json (3)

6-6: LGTM! Modern TypeScript execution with tsx.

The migration from ts-node to tsx for both the dev script and Prisma seed command is a solid modernization choice—tsx offers faster startup and better ESM support.

Also applies to: 20-20, 24-24


10-11: LGTM! Prisma packages aligned and up to date.

The Prisma packages are correctly aligned at version 6.17.1 (latest patch as of October 2025), and the addition of @prisma/extension-accelerate 2.0.2 supports the withAccelerate() usage in the seed and plugin files.

Based on learnings

Also applies to: 19-19


13-13: LGTM! dotenv added for environment configuration.

The dotenv package at ^17.2.3 is correctly added to support the dotenv/config side-effect imports used in the plugin files.

Based on learnings

orm/hapi/prisma/seed.ts (1)

1-1: LGTM! Import path updated to generated client location.

The import correctly references the locally generated Prisma client at ../src/generated/prisma/client, which aligns with the output path configured in schema.prisma.

orm/hapi/src/plugins/prisma.ts (2)

1-1: LGTM! Import path updated to generated client location.

The import correctly references the locally generated Prisma client at ../generated/prisma/client (resolves to src/generated/prisma/client).


4-4: LGTM! Environment variables loaded via dotenv side-effect import.

The dotenv/config import ensures .env variables are loaded before the Prisma client is instantiated. This is the recommended pattern for side-effect imports.

orm/hapi/src/plugins/users.ts (1)

2-2: LGTM! Import path updated to generated client location.

The Prisma types import correctly references the locally generated client at ../generated/prisma/client (resolves to src/generated/prisma/client).

orm/hapi/prisma/schema.prisma (1)

2-4: Prisma generator config is valid provider="prisma-client" and engineType="client" are supported since v6.16.0, and src/generated/prisma is excluded by root .gitignore.

orm/koa/package.json (2)

10-12: Verify Prisma version compatibility and dependencies.

The Prisma packages are updated to 6.17.1, dotenv is added for environment variable loading, and @prisma/extension-accelerate is added to enable Prisma Accelerate functionality. Ensure that:

  1. The generated client at ../src/generated/prisma is regenerated after these dependency updates by running npx prisma generate.
  2. A .env file exists with the required DATABASE_URL for the PrismaClient to connect.

Based on learnings: Prisma 6.17.1 is a patch release fixing Unsupported type diffing, and keeping prisma and @prisma/client versions aligned is a best practice.


21-21: LGTM on tsx migration.

Replacing ts-node with tsx provides faster TypeScript execution with better ESM support.

orm/koa/prisma/schema.prisma (2)

3-4: LGTM on custom output configuration.

The engineType and output configuration direct the Prisma generator to emit the client to a custom location (../src/generated/prisma), which aligns with the import paths used in src/index.ts and prisma/seed.ts.


2-2: Provider "prisma-client" is valid — npx prisma generate succeeded

@@ -1,4 +1,4 @@
import { PrismaClient, Prisma } from '@prisma/client'
import { PrismaClient, Prisma } from '../src/generated/prisma/client'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add dotenv initialization for seed script.

The seed script imports PrismaClient which requires DATABASE_URL from the environment. However, there's no dotenv initialization to load environment variables from .env. This will cause the seed script to fail if DATABASE_URL is only defined in .env and not already exported in the shell environment.

Apply this diff to add dotenv initialization:

+import 'dotenv/config'
 import { PrismaClient, Prisma } from '../src/generated/prisma/client'
 import { withAccelerate } from '@prisma/extension-accelerate'
🤖 Prompt for AI Agents
In orm/koa/prisma/seed.ts around line 1, the seed script imports PrismaClient
but doesn’t load environment variables from .env; add dotenv initialization at
the very top of the file (before any Prisma or other imports) so .env values
like DATABASE_URL are loaded into process.env (e.g. use
require('dotenv').config() or import 'dotenv/config' as appropriate for the
project runtime).

Comment on lines +4 to +5
import { Prisma, PrismaClient } from './generated/prisma/client'
import 'dotenv/config'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: dotenv must load before PrismaClient import.

The dotenv/config import on line 5 loads environment variables into process.env, but it appears after the PrismaClient import on line 4. Since PrismaClient needs DATABASE_URL from the environment at construction time (line 13), this ordering may cause the client to fail to connect if DATABASE_URL is only defined in .env and not already in the environment.

Apply this diff to fix the import ordering:

 import Koa from 'koa'
 import Router from '@koa/router'
 
-import { Prisma, PrismaClient } from './generated/prisma/client'
 import 'dotenv/config'
+import { Prisma, PrismaClient } from './generated/prisma/client'
 
 import { koaBody } from 'koa-body'
 import { withAccelerate } from '@prisma/extension-accelerate'
📝 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
import { Prisma, PrismaClient } from './generated/prisma/client'
import 'dotenv/config'
import Koa from 'koa'
import Router from '@koa/router'
import 'dotenv/config'
import { Prisma, PrismaClient } from './generated/prisma/client'
import { koaBody } from 'koa-body'
import { withAccelerate } from '@prisma/extension-accelerate'
🤖 Prompt for AI Agents
In orm/koa/src/index.ts around lines 4-5, the side-effect import 'dotenv/config'
must be executed before importing PrismaClient because PrismaClient reads
DATABASE_URL at construction (line 13); fix by moving the import 'dotenv/config'
to the top of the file (above the Prisma/PrismaClient import) or explicitly call
dotenv.config() before importing/instantiating PrismaClient so environment
variables from .env are loaded first.

Copy link

@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: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 920131d and addff3e.

⛔ Files ignored due to path filters (10)
  • orm/nest/src/generated/prisma/browser.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/client.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/commonInputTypes.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/enums.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/internal/class.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/internal/prismaNamespace.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/internal/prismaNamespaceBrowser.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/models.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/models/Post.ts is excluded by !**/generated/**
  • orm/nest/src/generated/prisma/models/User.ts is excluded by !**/generated/**
📒 Files selected for processing (5)
  • orm/nest/README.md (1 hunks)
  • orm/nest/package.json (2 hunks)
  • orm/nest/prisma/schema.prisma (1 hunks)
  • orm/nest/prisma/seed.ts (1 hunks)
  • orm/nest/src/app.controller.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • orm/nest/prisma/seed.ts
⏰ 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: test (orm/nest-graphql)
  • GitHub Check: test (orm/grpc)
  • GitHub Check: test (orm/nest-graphql-sdl-first)
  • GitHub Check: test (orm/nuxt)
🔇 Additional comments (6)
orm/nest/package.json (2)

75-75: Inconsistency: AI summary mentions tsx but ts-node is still used.

The AI-generated summary states "replaces ts-node with tsx for dev/seed scripts," but the seed script at line 75 still uses ts-node prisma/seed.ts.

Please verify whether:

  1. The tsx migration was intended for this file but missed, or
  2. The AI summary incorrectly assumed this change applied to all frameworks when it only applies to express/fastify/others.

If tsx migration is intended, the seed command should be updated to:

-    "seed": "ts-node prisma/seed.ts"
+    "seed": "tsx prisma/seed.ts"

And tsx should be added to devDependencies.


44-49: Verified: Prisma Accelerate initialization and version sync
All PrismaClient instances in the Nest module import and extend with withAccelerate(). Both @prisma/client and prisma remain at version 6.17.1 in orm/nest/package.json.

orm/nest/README.md (1)

351-351: LGTM! Documentation updated to reflect generated client path.

The import example correctly shows the new path ./generated/prisma/client, consistent with the generator output configuration in prisma/schema.prisma.

orm/nest/src/app.controller.ts (1)

12-12: Verified Prisma client generation path
Schema’s output = "../src/generated/prisma" aligns with ./generated/prisma/client, and orm/nest/src/generated exists.

orm/nest/prisma/schema.prisma (2)

4-4: Prisma output path aligns with imports. Running npx prisma generate in orm/nest outputs to ./src/generated/prisma, matching the ./generated/prisma/client imports in app.controller.ts and documentation.


1-5: Valid Prisma v6 generator configuration
provider = "prisma-client" (ESM-first generator) with engineType = "client" and a custom output path is supported in Prisma 6.x.

Comment on lines +12 to +13
import { User as UserModel, Post as PostModel, Prisma } from './generated/prisma/client';
import 'dotenv/config'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Move dotenv initialization to main.ts (NestJS best practice).

Loading environment variables in a controller violates NestJS initialization order and can cause race conditions. The dotenv/config import has side effects that mutate process.env, and this should happen before the application bootstrap—not during controller instantiation.

Recommended approach: Remove the dotenv import from this file and add it to the main.ts entry point:

In app.controller.ts, remove the dotenv import:

 import { User as UserModel, Post as PostModel, Prisma } from './generated/prisma/client';
-import 'dotenv/config'

In src/main.ts (or wherever NestJS app is bootstrapped), add it at the very top:

import 'dotenv/config'; // Must be first
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  // ... rest of bootstrap
}
bootstrap();

This ensures environment variables are loaded before PrismaService and other services are instantiated. Based on learnings, dotenv.config() should be called "as early as possible (before other modules that read process.env)."

🤖 Prompt for AI Agents
In orm/nest/src/app.controller.ts around lines 12-13, remove the side-effect
import "import 'dotenv/config'" from the controller; dotenv must be initialized
before Nest bootstrap to avoid race conditions. Open your app entry (e.g.,
src/main.ts) and add "import 'dotenv/config'" as the very first
import/top-of-file so environment variables are loaded before NestFactory.create
and any services (PrismaService, controllers) are instantiated; then run the app
to verify env values are available during bootstrap.

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