-
Notifications
You must be signed in to change notification settings - Fork 1.5k
update express.js project #8326
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
base: latest
Are you sure you want to change the base?
Conversation
WalkthroughSwitches 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
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: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (10)
orm/express/src/generated/prisma/browser.tsis excluded by!**/generated/**orm/express/src/generated/prisma/client.tsis excluded by!**/generated/**orm/express/src/generated/prisma/commonInputTypes.tsis excluded by!**/generated/**orm/express/src/generated/prisma/enums.tsis excluded by!**/generated/**orm/express/src/generated/prisma/internal/class.tsis excluded by!**/generated/**orm/express/src/generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**orm/express/src/generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**orm/express/src/generated/prisma/models.tsis excluded by!**/generated/**orm/express/src/generated/prisma/models/Post.tsis excluded by!**/generated/**orm/express/src/generated/prisma/models/User.tsis 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.jsonorm/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 inschema.prismathat outputs to../src/generated/prisma.Verify that the path resolves correctly: from
src/index.ts, the import./generated/prisma/clientshould find the generated client atsrc/generated/prisma/client.
4-6: LGTM: dotenv initialization correctly placed; README documents .env creation for DATABASE_URLorm/express/package.json (4)
6-6: LGTM: Modern tsx replacing ts-node for development.The switch from
ts-nodetotsxfor the dev script is a good modernization choice.tsxis 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
tsxinstead ofts-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/clientto../src/generated/prisma/client, which resolves fromprisma/seed.tsto the generated client atsrc/generated/prisma/client. This change is consistent with the generator configuration inschema.prismaand the import insrc/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"andengineType = "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", |
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.
🧩 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).
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: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 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.jsonorm/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/clientis correct relative to this seed file's location.orm/fastify/package.json (2)
6-6: LGTM! Modern script runner.Replacing
ts-nodewithtsxis a good modernization choice for faster TypeScript execution.
20-20: LGTM! Seed script updated consistently.The seed script now uses
tsxinstead ofts-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.
| "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" |
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.
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.
| "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.
| import { Prisma, PrismaClient } from './generated/prisma/client' | ||
| import { withAccelerate } from '@prisma/extension-accelerate' | ||
|
|
||
| import fastify from 'fastify' | ||
| import 'dotenv/config' |
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.
🧩 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.
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: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (20)
orm/fastify/src/generated/prisma/browser.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/client.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/commonInputTypes.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/enums.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/internal/class.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/models.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/models/Post.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/models/User.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/browser.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/client.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/commonInputTypes.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/enums.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/internal/class.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/models.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/models/Post.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/models/User.tsis 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.jsonorm/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
prismaand@prisma/client.Based on learnings.
Also applies to: 19-20
6-6: LGTM! tsx replacement is appropriate.Replacing
ts-nodewithtsxfor 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 inschema.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/configis 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 customoutputpath are valid and recommended in Prisma 6.17.1. No changes required.
| import { PrismaClient, Prisma } from '../src/generated/prisma/client' | ||
| import { withAccelerate } from '@prisma/extension-accelerate' | ||
|
|
||
| const prisma = new PrismaClient().$extends(withAccelerate()) |
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.
🛠️ 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 2Length 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.
| 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.
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: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (30)
orm/fastify/src/generated/prisma/browser.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/client.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/commonInputTypes.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/enums.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/internal/class.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/models.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/models/Post.tsis excluded by!**/generated/**orm/fastify/src/generated/prisma/models/User.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/browser.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/client.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/commonInputTypes.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/enums.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/internal/class.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/models.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/models/Post.tsis excluded by!**/generated/**orm/hapi/src/generated/prisma/models/User.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/browser.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/client.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/commonInputTypes.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/enums.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/internal/class.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/models.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/models/Post.tsis excluded by!**/generated/**orm/koa/src/generated/prisma/models/User.tsis 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.tsorm/koa/prisma/seed.tsorm/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-nodetotsxfor 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-accelerate2.0.2 supports thewithAccelerate()usage in the seed and plugin files.Based on learnings
Also applies to: 19-19
13-13: LGTM! dotenv added for environment configuration.The
dotenvpackage at ^17.2.3 is correctly added to support thedotenv/configside-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 inschema.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 tosrc/generated/prisma/client).
4-4: LGTM! Environment variables loaded via dotenv side-effect import.The
dotenv/configimport ensures.envvariables 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 tosrc/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, andsrc/generated/prismais 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:
- The generated client at
../src/generated/prismais regenerated after these dependency updates by runningnpx prisma generate.- A
.envfile exists with the requiredDATABASE_URLfor 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-nodewithtsxprovides faster TypeScript execution with better ESM support.orm/koa/prisma/schema.prisma (2)
3-4: LGTM on custom output configuration.The
engineTypeandoutputconfiguration direct the Prisma generator to emit the client to a custom location (../src/generated/prisma), which aligns with the import paths used insrc/index.tsandprisma/seed.ts.
2-2: Provider"prisma-client"is valid —npx prisma generatesucceeded
| @@ -1,4 +1,4 @@ | |||
| import { PrismaClient, Prisma } from '@prisma/client' | |||
| import { PrismaClient, Prisma } from '../src/generated/prisma/client' | |||
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.
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).
| import { Prisma, PrismaClient } from './generated/prisma/client' | ||
| import 'dotenv/config' |
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.
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.
| 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.
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: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (10)
orm/nest/src/generated/prisma/browser.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/client.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/commonInputTypes.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/enums.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/internal/class.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/internal/prismaNamespace.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/internal/prismaNamespaceBrowser.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/models.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/models/Post.tsis excluded by!**/generated/**orm/nest/src/generated/prisma/models/User.tsis 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:
- The tsx migration was intended for this file but missed, or
- 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
AllPrismaClientinstances in the Nest module import and extend withwithAccelerate(). Both@prisma/clientandprismaremain at version6.17.1inorm/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 inprisma/schema.prisma.orm/nest/src/app.controller.ts (1)
12-12: Verified Prisma client generation path
Schema’soutput = "../src/generated/prisma"aligns with./generated/prisma/client, andorm/nest/src/generatedexists.orm/nest/prisma/schema.prisma (2)
4-4: Prisma output path aligns with imports. Runningnpx prisma generateinorm/nestoutputs to./src/generated/prisma, matching the./generated/prisma/clientimports inapp.controller.tsand documentation.
1-5: Valid Prisma v6 generator configuration
provider = "prisma-client"(ESM-first generator) withengineType = "client"and a customoutputpath is supported in Prisma 6.x.
| import { User as UserModel, Post as PostModel, Prisma } from './generated/prisma/client'; | ||
| import 'dotenv/config' |
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.
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.
Summary by CodeRabbit
New Features
Chores
Refactor