🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

create-worker-app

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-worker-app

Create Cloudflare Workers apps with Hono.js

Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

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 dev

Or install globally:

npm install -g create-worker-app
create-worker-app my-app

Alternative: Install from GitHub Packages

This package is also available on GitHub Packages:

npx @leeguooooo/create-worker-app@latest 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

npm run generate:route

Choose 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 Resource

CRUD 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/docs

Deploy to Cloudflare

# Deploy to development
npm run deploy

# Deploy to staging
npm run deploy:staging

# Deploy to production
npm run deploy:production

📋 Template Comparison

TemplateUse CaseFeatures
BasicStandard API endpointsRequest validation, error handling
CRUD ResourceRESTful resourcesFull CRUD operations, pagination
With AuthProtected APIsJWT validation, user context
Webhook HandlerExternal callbacksSignature 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

Built with ❤️ for Edge Computing

Keywords

cloudflare

FAQs

Package last updated on 06 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts