Example of using Elysia with Prisma ORM on the Bun runtime.
- Framework: Elysia
- ORM: Prisma
- Runtime: Bun
- Database: PostgreSQL
- Validation: Prismabox
- Bun installed
- PostgreSQL database running
- Download the example and install dependencies:
bunx --bun try-prisma@latest --template orm/elysia --name hono
cd hono- Install dependencies:
bun install- Create
.env.localfrom the example:
cp .env.example .env.local- Configure database connection in
.env.local:
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
- Generate Prisma client:
bunx --bun prisma generate- Run migrations:
bunx --bun prisma migrate devStart the development server:
bun run devServer runs at http://localhost:3000
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
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
curl -X PUT http://localhost:3000 \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","name":"John"}'curl http://localhost:3000/id/1After modifying prisma/schema.prisma:
bunx prisma generate