0.0.2 • Published 5 months ago
@johnlindquist/nx-hono v0.0.2
@johnlindquist/nx-hono
An Nx plugin for Hono - a fast, lightweight web framework built on Web Standards that works on any JavaScript runtime.
Features
- 🚀 Multi-runtime support: Cloudflare Workers, Node.js, Deno, Bun, Vercel Edge, Netlify Edge
- 🏗️ Project generators: Create Hono applications with proper Nx integration
- 🛠️ Code generators: Generate API routes and middleware
- ⚡ Development server: Serve applications with hot reload
- 📦 Build system: Build applications for production
- 🚀 Deployment: Deploy to various platforms
Installation
npm install @johnlindquist/nx-honoGenerators
Initialize Hono Support
Add Hono support to your Nx workspace:
nx g @johnlindquist/nx-hono:initCreate a Hono Application
Generate a new Hono application:
nx g @johnlindquist/nx-hono:application my-apiOptions:
--runtime: Target runtime (cloudflare-workers, node, deno, bun, vercel, netlify)--directory: Directory to create the application in--tags: Tags for the application
Generate API Routes
Create new API routes:
nx g @johnlindquist/nx-hono:api users --project=my-apiOptions:
--methods: HTTP methods to support (GET, POST, PUT, DELETE, PATCH)--directory: Directory within the project to create the route
Generate Middleware
Create custom middleware:
nx g @johnlindquist/nx-hono:middleware auth --project=my-apiOptions:
--type: Type of middleware (custom, auth, cors, logger, rate-limit)--directory: Directory within the project to create the middleware
Executors
Serve
Start a development server:
nx serve my-apiBuild
Build the application for production:
nx build my-apiDeploy
Deploy the application:
nx deploy my-apiRuntime-Specific Features
Cloudflare Workers
- Automatic
wrangler.tomlconfiguration - TypeScript support with Cloudflare Workers types
- Built-in CORS and logging middleware
Node.js
- Express-like development experience
- Built-in server with
@hono/node-server
Deno
- Native Deno support
- Web Standards compliance
Bun
- Ultra-fast development with Bun runtime
- Native TypeScript support
Example Usage
- Initialize Hono support:
nx g @johnlindquist/nx-hono:init- Create a new Hono application:
nx g @johnlindquist/nx-hono:application my-api --runtime=cloudflare-workers- Generate an API route:
nx g @johnlindquist/nx-hono:api users --project=my-api --methods=GET,POST- Generate middleware:
nx g @johnlindquist/nx-hono:middleware auth --project=my-api --type=auth- Start development server:
nx serve my-api- Build for production:
nx build my-api- Deploy:
nx deploy my-apiLearn More
Contributing
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
License
MIT