Package Exports
- create-worker-app
- create-worker-app/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (create-worker-app) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
create-worker-app
đ The fastest way to create Cloudflare Workers applications with Hono.js
⨠Features
- âĄī¸ Lightning Fast - Built on Hono.js, optimized for edge computing
- đ TypeScript First - Full type support and IntelliSense
- đ Auto API Documentation - OpenAPI/Swagger integration, visit
/docs - đ ī¸ Smart Route Generator - Interactive CLI for creating CRUD, Auth, Webhook templates
- đ¯ Production Ready - Built-in error handling, CORS, logging middleware
- đ One-Click Deploy - Pre-configured Wrangler for multi-environment deployment
đââī¸ Quick Start
Using npx (recommended):
npx create-worker-app my-app
cd my-app
npm install
npm run devOr install globally:
npm install -g create-worker-app
create-worker-app my-appđŽ Interactive Setup
The CLI will guide you through the setup:
đ Create Worker App
â Project name: my-awesome-api
â Project description: A high-performance API service
â Will you need database configuration? âĻ No
â Include OpenAPI/Swagger documentation? âĻ Yes
đ Creating project...
â
Project created successfully!đī¸ Project Structure
my-app/
âââ src/
â âââ index.ts # Application entry
â âââ types/ # TypeScript type definitions
â â âââ env.ts # Environment types
â âââ routes/ # API routes
â â âââ health.ts # Health check example
â âââ schemas/ # Zod validation schemas
â â âââ common.ts # Common schemas
â âââ lib/ # Utilities
â âââ openapi.ts # OpenAPI configuration
âââ scripts/
â âââ generate-route.js # Route generator
âââ wrangler.toml # Cloudflare Workers config
âââ tsconfig.json # TypeScript config
âââ package.json
âââ README.mdđĨ Powerful Route Generator
Interactive Mode (Recommended)
npm run generate:routeChoose from templates:
- Basic - Standard API route
- CRUD Resource - Full REST endpoints
- With Auth - JWT authenticated route
- Webhook Handler - External webhook receiver
CLI Mode
# Generate basic route
npm run generate:route createUser post /api/users
# Generate authenticated route
npm run generate:route getProfile get /api/profile auth
# Generate CRUD resource (creates 5 endpoints)
npm run generate:route -- # Then select CRUD ResourceCRUD Generation Example
When selecting CRUD Resource:
â
Created schema: src/schemas/product.ts
â
Created CRUD routes: src/routes/product.ts
â
Updated index.ts
Created endpoints:
- GET /api/products - List all products
- GET /api/products/{id} - Get single product
- POST /api/products - Create new product
- PATCH /api/products/{id} - Update product
- DELETE /api/products/{id} - Delete productđ Development & Deployment
Local Development
npm run dev
# Visit http://localhost:8787
# API docs at http://localhost:8787/docsDeploy to Cloudflare
# Deploy to development
npm run deploy
# Deploy to staging
npm run deploy:staging
# Deploy to production
npm run deploy:productionđ Template Comparison
| Template | Use Case | Features |
|---|---|---|
| Basic | Standard API endpoints | Request validation, error handling |
| CRUD Resource | RESTful resources | Full CRUD operations, pagination |
| With Auth | Protected APIs | JWT validation, user context |
| Webhook Handler | External callbacks | Signature verification, event handling |
đ§ Configuration
Database Support
If you enable database configuration, a .env.example file will be created:
DB_HOST=
DB_PORT=
DB_NAME=
DB_USER=
DB_PASSWORD=Environment Types
All environment variables are fully typed:
// src/types/env.ts
export interface Env {
// Your environment variables
API_KEY: string;
DB_URL?: string;
}đ¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
đ License
MIT