A template for building APIs using Hono.js with Prisma ORM, designed for deployment on Cloudflare Workers.
- 🚀 Hono.js - Fast, Lightweight, Web-standards
- 🛠 Prisma ORM with PostgreSQL
- ⚡ Prisma Accelerate Support
- 🔒 Environment Variable Validation with Zod
- 📦 TypeScript Support
- Node.js 18+
- PostgreSQL Database
- Cloudflare Account (for deployment)
- Clone the repository and install dependencies:
npm install
- Create a
.dev.vars
file based on the.dev.vars.example
file:
cp .dev.vars.example .dev.vars
- Run the database migration and seeding:
npm run db:prisma
npm run db:migrate
npm run db:seed
- Start the development server:
npm run dev
- Deploy the application to Cloudflare Workers:
npm run db:no-engine
npm run deploy
- Visit the deployed application in your browser:
https://<your-subdomain>.workers.dev
The application uses PostgreSQL as the database. You can configure the database connection in the .dev.vars
file.
- DATABASE_URL: The database URL for the production environment which is an accelerated database from Prisma Accelerate.
- DATABASE_URL_UNPOOLED: This is the database URL for the development environment which is a non-accelerated database.
The application uses environment variables to configure the database connection. You can configure the database connection in the .dev.vars
file.
To deploy the application to Cloudflare Workers, you need to have a Cloudflare account and install the Wrangler CLI.
- Install the Wrangler CLI:
npm install -g wrangler
- Authenticate the Wrangler CLI:
wrangler login
- generate prisma client -no-engine
npm run db:no-engine
- Deploy the application to Cloudflare Workers:
npm run deploy
- Visit the deployed application in your browser:
https://<your-subdomain>.workers.dev