Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elysia + Prisma with Bun

Example of using Elysia with Prisma ORM on the Bun runtime.

Stack

  • Framework: Elysia
  • ORM: Prisma
  • Runtime: Bun
  • Database: PostgreSQL
  • Validation: Prismabox

Quick Start

Prerequisites

  • Bun installed
  • PostgreSQL database running

Setup

  1. Download the example and install dependencies:
bunx --bun try-prisma@latest --template orm/elysia --name hono
cd hono
  1. Install dependencies:
bun install
  1. Create .env.local from the example:
cp .env.example .env.local
  1. Configure database connection in .env.local:
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
  1. Generate Prisma client:
bunx --bun prisma generate
  1. Run migrations:
bunx --bun prisma migrate dev

Development

Start the development server:

bun run dev

Server runs at http://localhost:3000

Project Structure

prisma/
├── schema.prisma          # Database schema
├── generated/             # Generated files (not committed)
│   ├── client/           # Prisma client
│   └── prismabox/        # Type validators
└── migrations/           # Database migrations (not committed)

src/
└── index.ts              # Application entry point

Database Schema

The example includes two models:

  • User: id, email, name, posts
  • Post: id, title, content, published, author, authorId

View and edit the schema in prisma/schema.prisma

API

Create User

curl -X PUT http://localhost:3000 \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","name":"John"}'

Get User by ID

curl http://localhost:3000/id/1

Regenerating Prisma Client

After modifying prisma/schema.prisma:

bunx prisma generate

Learn More

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages