Skip to content

Conversation

@MrUprizing
Copy link

@MrUprizing MrUprizing commented Nov 29, 2025

Example of using Prisma ORM with Elysia framework on Bun runtime and PostgreSQL.

Includes setup, type-safe database operations, automatic validation with Prismabox, and RESTful API endpoints.

Summary by CodeRabbit

  • New Features

    • Added a new Elysia + Prisma example project with PostgreSQL integration using Bun runtime.
    • Includes API endpoints for user creation and retrieval.
  • Documentation

    • Added comprehensive README with quick start guide, project structure, database schema overview, and API usage examples.
  • Chores

    • Added project configuration and environment setup files.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Walkthrough

New Elysia + Prisma example project with PostgreSQL backend. Introduces project structure including environment configuration, TypeScript setup, Prisma schema with User and Post models, package dependencies, and a server implementation with two API routes for creating and retrieving users.

Changes

Cohort / File(s) Summary
Configuration & Environment
orm/elysia/.env.example, orm/elysia/.gitignore, orm/elysia/tsconfig.json
Added environment variable example (DATABASE_URL), standard gitignore patterns for Node.js/Bun projects, and TypeScript configuration with ES2021 target, strict type checking, and bun-types support
Project Metadata & Documentation
orm/elysia/package.json, orm/elysia/README.md
Added package manifest defining Elysia + Prisma project with dev/prod dependencies (@prisma/client, @prisma/adapter-pg, elysia, pg, prisma), scripts, and Bun package manager; added README with setup instructions, project structure, schema overview, and API usage examples
Prisma Schema & Configuration
orm/elysia/prisma.config.ts, orm/elysia/prisma/schema.prisma
Added Prisma configuration reading DATABASE_URL from environment; defined schema with PostgreSQL datasource, Prisma Client and Prismabox generators, and two models: User (with id, email, name, and relation to posts) and Post (with id, title, content, published flag, and relation to author)
Server Implementation
orm/elysia/src/index.ts
Added Elysia HTTP server with PrismaPg adapter using connection pool from DATABASE_URL; implemented POST / route to create users and GET /id/:id route to fetch users by id with 404 handling; server runs on port 3000

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring attention:

  • prisma/schema.prisma: Verify User-Post relationship cardinality is correct (one-to-many) and foreign key constraints are properly defined with cascading behaviors if needed
  • src/index.ts: Review Elysia route handlers for comprehensive error handling beyond 404 responses, input validation for POST body, and that Prismabox types (UserPlainInputCreate, UserPlain) are correctly generated
  • package.json: Confirm all listed dependencies (particularly @prisma/adapter-pg, prismabox) are necessary and versions are compatible with Elysia and Prisma
  • prisma.config.ts: Validate environment variable error handling and that migrations path configuration aligns with project structure

Possibly related PRs

  • Update databases examples #8374: Adds prisma.config.ts, updates package.json with @prisma/adapter-pg, and wires Prisma to use the PrismaPg adapter in the same manner for another Prisma example project

Pre-merge checks

✅ 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 directly and clearly summarizes the main addition: a new Elysia + Prisma example project with Bun runtime, which matches the changeset containing project setup files, configuration, schema, and API implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent 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 c1fc715 and a6e6415.

📒 Files selected for processing (8)
  • orm/elysia/.env.example (1 hunks)
  • orm/elysia/.gitignore (1 hunks)
  • orm/elysia/README.md (1 hunks)
  • orm/elysia/package.json (1 hunks)
  • orm/elysia/prisma.config.ts (1 hunks)
  • orm/elysia/prisma/schema.prisma (1 hunks)
  • orm/elysia/src/index.ts (1 hunks)
  • orm/elysia/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/fastify-graphql-sdl-first/src/context.ts:1-1
Timestamp: 2025-10-27T13:18:46.546Z
Learning: The prisma/prisma-examples repository is a monorepo containing many independent example projects. When reviewing PRs in this repository, focus only on the files actually changed by the author in that specific PR, not on other example projects or infrastructure that wasn't modified.
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/betterauth-astro/src/pages/sign-up/index.astro:20-36
Timestamp: 2025-10-24T17:50:48.569Z
Learning: Do not suggest code changes or improvements to code in Prisma example repositories (prisma/prisma-examples). These examples are carefully set up and intentionally aligned with external documentation and information.
📚 Learning: 2025-08-22T12:12:24.602Z
Learnt from: FGoessler
Repo: prisma/prisma-examples PR: 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/elysia/tsconfig.json
  • orm/elysia/prisma.config.ts
  • orm/elysia/package.json
  • orm/elysia/.gitignore
📚 Learning: 2025-10-15T13:58:59.096Z
Learnt from: AmanVarshney01
Repo: prisma/prisma-examples PR: 8327
File: orm/graphql-auth/prisma/schema.prisma:2-4
Timestamp: 2025-10-15T13:58:59.096Z
Learning: The "prisma-client" generator provider (introduced in Prisma v6) is the newer, ESM-ready alternative to "prisma-client-js". It requires an explicit output path and is better suited for modern runtimes, edge deployments, and will become the default in Prisma v7. Use "prisma-client" for new projects or when modernizing existing projects.

Applied to files:

  • orm/elysia/prisma.config.ts
  • orm/elysia/package.json
  • orm/elysia/prisma/schema.prisma
📚 Learning: 2025-10-27T13:18:46.546Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/fastify-graphql-sdl-first/src/context.ts:1-1
Timestamp: 2025-10-27T13:18:46.546Z
Learning: The prisma/prisma-examples repository is a monorepo containing many independent example projects. When reviewing PRs in this repository, focus only on the files actually changed by the author in that specific PR, not on other example projects or infrastructure that wasn't modified.

Applied to files:

  • orm/elysia/package.json
  • orm/elysia/README.md
📚 Learning: 2025-10-27T13:18:46.546Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/fastify-graphql-sdl-first/src/context.ts:1-1
Timestamp: 2025-10-27T13:18:46.546Z
Learning: In the prisma/prisma-examples repository, generated Prisma client files (typically at paths like `prisma/generated/client`) are intentionally not committed to the repository. These files are generated at build/test time. Do not flag missing generated client artifacts as issues in reviews.

Applied to files:

  • orm/elysia/.gitignore
  • orm/elysia/prisma/schema.prisma
📚 Learning: 2025-10-24T17:50:48.569Z
Learnt from: aidankmcalister
Repo: prisma/prisma-examples PR: 8334
File: orm/betterauth-astro/src/pages/sign-up/index.astro:20-36
Timestamp: 2025-10-24T17:50:48.569Z
Learning: Do not suggest code changes or improvements to code in Prisma example repositories (prisma/prisma-examples). These examples are carefully set up and intentionally aligned with external documentation and information.

Applied to files:

  • orm/elysia/README.md
📚 Learning: 2025-10-15T13:58:29.130Z
Learnt from: AmanVarshney01
Repo: prisma/prisma-examples PR: 8327
File: orm/fastify-graphql/prisma/schema.prisma:2-4
Timestamp: 2025-10-15T13:58:29.130Z
Learning: In Prisma v6.15 and later, `provider = "prisma-client"` is a valid generator configuration value when combined with `engineType = "client"`. This configuration generates a Prisma client without Rust engine binaries, relying on JavaScript driver adapters instead, and is different from the traditional `provider = "prisma-client-js"` configuration.

Applied to files:

  • orm/elysia/prisma/schema.prisma
📚 Learning: 2025-10-15T13:56:01.807Z
Learnt from: AmanVarshney01
Repo: prisma/prisma-examples PR: 8327
File: orm/graphql-subscriptions/prisma/schema.prisma:1-5
Timestamp: 2025-10-15T13:56:01.807Z
Learning: In Prisma v6.15 and later, `engineType = "client"` is a valid generator configuration value that generates a Prisma client without Rust engine binaries, relying on JavaScript driver adapters instead (e.g., prisma/adapter-pg). This is useful for edge and serverless deployments.

Applied to files:

  • orm/elysia/prisma/schema.prisma
🪛 dotenv-linter (4.0.0)
orm/elysia/.env.example

[warning] 1-1: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

🪛 markdownlint-cli2 (0.18.1)
orm/elysia/README.md

39-39: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


64-64: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (8)
orm/elysia/README.md (1)

1-112: README content is consistent with the new example’s code and structure

Stack description, setup steps (Bun + Prisma commands, env file), project tree, database schema, and API examples (PUT /, GET /id/:id) all line up with src/index.ts and prisma/schema.prisma. From a correctness perspective the docs accurately describe how to run and use this example. Based on learnings, not suggesting structural changes to this example.

orm/elysia/.gitignore (1)

1-46: .gitignore matches expected patterns for a Bun + Prisma example

Ignore rules cover dependencies, build artifacts, logs, archives, env files, and Prisma generated client/migrations, aligning with how prisma-examples manages generated assets. Based on learnings, this is consistent with other examples in the monorepo.

orm/elysia/.env.example (1)

1-1: DATABASE_URL example aligns with Prisma config and runtime usage

The example DATABASE_URL matches what prisma.config.ts and the pg Pool in src/index.ts expect, so it’s a good, working default for local development.

orm/elysia/src/index.ts (1)

1-51: Elysia server, PrismaPg adapter, and Prismabox wiring look coherent

PostgreSQL connection via Pool(DATABASE_URL), Prisma client construction with the PrismaPg adapter, and the two routes (PUT / with UserPlainInputCreate body / UserPlain response, GET /id/:id with 404 or UserPlain) all line up with the schema and README. The logging of app.server?.hostname/port is also safe via optional chaining. Please run the example with your target Bun/Prisma/Elysia versions to confirm everything behaves as expected end‑to‑end.

orm/elysia/prisma.config.ts (1)

1-16: Prisma configuration correctly centralizes schema, migrations, and datasource URL

Using defineConfig with schema: "prisma/schema.prisma", migrations.path: "prisma/migrations", and datasource.url from DATABASE_URL is consistent with the example’s structure. The explicit check that DATABASE_URL is set will surface misconfiguration early when running Prisma commands; just ensure this env var is present in the environment Prisma runs in (as documented in the README).

orm/elysia/package.json (1)

1-22: Package manifest matches the Bun + Prisma + Elysia stack used in the example

Declared dependencies and devDependencies line up with the code (Prisma client + adapter, Elysia, pg, Prismabox, and the Prisma CLI), and the dev script using Bun with src/index.ts matches the README’s development instructions. The Bun packageManager metadata also fits this example.

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

1-33: Prisma schema, generators, and models align with the example’s runtime and API

The prisma-client generator with runtime = "bun" and explicit output path, the PostgreSQL datasource (URL supplied via prisma.config.ts), and the prismabox generator configuration all match how the example uses the generated client and validators. The User and Post models also align with what the README and HTTP handlers expect.

orm/elysia/tsconfig.json (1)

1-102: I need to verify the Bun types configuration concern. Let me gather information about the actual package configuration and Bun's type definitions setup.
<function_calls>

#!/bin/bash

Find and examine the package.json in orm/elysia

find . -path "*/orm/elysia/package.json" -type f -exec cat {} ;


</function_calls>
<function_calls>

Bun TypeScript types bun-types @types/bun correct setup configuration

</function_calls>

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

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.

1 participant