0.0.2 • Published 5 months ago

@johnlindquist/nx-hono v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@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-hono

Generators

Initialize Hono Support

Add Hono support to your Nx workspace:

nx g @johnlindquist/nx-hono:init

Create a Hono Application

Generate a new Hono application:

nx g @johnlindquist/nx-hono:application my-api

Options:

  • --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-api

Options:

  • --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-api

Options:

  • --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-api

Build

Build the application for production:

nx build my-api

Deploy

Deploy the application:

nx deploy my-api

Runtime-Specific Features

Cloudflare Workers

  • Automatic wrangler.toml configuration
  • 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

  1. Initialize Hono support:
nx g @johnlindquist/nx-hono:init
  1. Create a new Hono application:
nx g @johnlindquist/nx-hono:application my-api --runtime=cloudflare-workers
  1. Generate an API route:
nx g @johnlindquist/nx-hono:api users --project=my-api --methods=GET,POST
  1. Generate middleware:
nx g @johnlindquist/nx-hono:middleware auth --project=my-api --type=auth
  1. Start development server:
nx serve my-api
  1. Build for production:
nx build my-api
  1. Deploy:
nx deploy my-api

Learn More

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.

License

MIT

0.0.2

5 months ago

0.0.1

5 months ago