A Cloudflare Workers API built with Hono, Drizzle ORM, Turso (LibSQL), and Upstash Redis.
- Bun
- Cloudflare Account
- Turso Database account
- Upstash Redis account
git clone <repository-url>
cd credX-apinpm install
# or
bun installCreate a .env file in the root directory:
TURSO_DATABASE_URL=your-turso-database-url
TURSO_AUTH_TOKEN=your-turso-auth-token
REDIS_URL=your-upstash-redis-url
REDIS_TOKEN=your-upstash-redis-token
FRONTEND_URL=your-frontend-urlGetting the credentials:
- Turso Database:
- Sign up at turso.tech
- Create a new database
- Get the URL and auth token from the Turso dashboard
- Upstash Redis:
- Sign up at upstash.com
- Create a new Redis database
- Copy the REST URL and token from the database details
Update the vars section in wrangler.jsonc with your values:
Generate and push the database schema to Turso:
npm run drizzle:generate
npm run drizzle:pushGenerate TypeScript types based on your Worker configuration:
npm run cf-typegenStart the development server:
npm run devThe API will be available at http://localhost:8787
Deploy to Cloudflare Workers:
npm run deploynpm run dev- Start development server with Wranglernpm run build- Build the Workernpm run deploy- Deploy to Cloudflare Workers (minified)npm run cf-typegen- Generate CloudflareBindings typesnpm run drizzle:generate- Generate Drizzle migration filesnpm run drizzle:push- Push schema changes to database
Pass the CloudflareBindings as generics when instantiating Hono:
// src/index.ts
const app = new Hono<{ Bindings: CloudflareBindings }>();- Hono - Ultrafast web framework
- Drizzle ORM - TypeScript ORM
- Turso - SQLite-based edge database
- Upstash Redis - Serverless Redis
- Cloudflare Workers - Serverless compute platform
This project is licensed under the MIT License - see the LICENSE file for details.
{ "vars": { "TURSO_DATABASE_URL": "your-turso-database-url", "TURSO_AUTH_TOKEN": "your-turso-auth-token", "REDIS_URL": "your-upstash-redis-url", "REDIS_TOKEN": "your-upstash-redis-token", "FRONTEND_URL": "your-frontend-url" } }