hono-helper
Hono web framework for edge-first, lightweight APIs - routing, middleware, validation, and multi-runtime support When user works with Hono, builds APIs, creates middleware, uses Zod validation with Hono, or mentions hono patterns
What this skill does
# Hono Helper Agent
## What's New in Hono (2024-2025)
- **Multi-runtime**: Runs on Bun, Node.js, Deno, Cloudflare Workers, AWS Lambda, Vercel
- **RPC mode**: End-to-end type safety with `hc` client
- **Zod OpenAPI**: Generate OpenAPI specs from Zod schemas
- **Streaming**: First-class streaming response support
- **JSX middleware**: Server-side JSX rendering
- **Performance**: One of the fastest web frameworks (Bun benchmark leader)
## Installation
```bash
# For Bun
bun add hono
# For Node.js
npm install hono @hono/node-server
# For Cloudflare Workers
npm install hono
```
## Basic Application
### Bun Setup
```typescript
import { Hono } from "hono";
const app = new Hono();
app.get("/", (c) => c.text("Hello Hono!"));
export default app;
```
Bun automatically serves the default export on port 3000.
### Node.js Setup
```typescript
import { Hono } from "hono";
import { serve } from "@hono/node-server";
const app = new Hono();
app.get("/", (c) => c.text("Hello Hono!"));
serve({ fetch: app.fetch, port: 3000 });
```
## Routing
### HTTP Methods
```typescript
app.get("/users", (c) => c.json({ users: [] }));
app.post("/users", (c) => c.json({ created: true }));
app.put("/users/:id", (c) => c.json({ updated: true }));
app.patch("/users/:id", (c) => c.json({ patched: true }));
app.delete("/users/:id", (c) => c.json({ deleted: true }));
// All methods
app.all("/any", (c) => c.text("Any method"));
// Multiple methods
app.on(["GET", "POST"], "/multi", (c) => c.text("GET or POST"));
```
### Path Parameters
```typescript
// Single parameter
app.get("/users/:id", (c) => {
const id = c.req.param("id");
return c.json({ id });
});
// Multiple parameters
app.get("/posts/:postId/comments/:commentId", (c) => {
const { postId, commentId } = c.req.param();
return c.json({ postId, commentId });
});
// Optional parameter
app.get("/articles/:id?", (c) => {
const id = c.req.param("id") ?? "default";
return c.json({ id });
});
```
### Wildcards and Regex
```typescript
// Wildcard - matches any path segment
app.get("/files/*", (c) => {
const path = c.req.path;
return c.text(`File path: ${path}`);
});
// Regex constraint
app.get("/users/:id{[0-9]+}", (c) => {
const id = c.req.param("id"); // Guaranteed to be numeric
return c.json({ id: Number(id) });
});
```
### Route Grouping
```typescript
const api = new Hono();
api.get("/users", (c) => c.json({ users: [] }));
api.get("/posts", (c) => c.json({ posts: [] }));
const app = new Hono();
app.route("/api/v1", api);
// Routes: GET /api/v1/users, GET /api/v1/posts
```
### Chained Routes
```typescript
app
.get("/endpoint", (c) => c.text("GET"))
.post((c) => c.text("POST"))
.put((c) => c.text("PUT"));
```
## Context API
The `c` (context) object provides request/response utilities:
### Request Access
```typescript
app.get("/info", (c) => {
// URL and path
const url = c.req.url;
const path = c.req.path;
const method = c.req.method;
// Query parameters
const page = c.req.query("page");
const allQueries = c.req.queries("tag"); // Array for repeated params
// Headers
const auth = c.req.header("Authorization");
const allHeaders = c.req.header(); // All headers
return c.json({ url, path, method, page, auth });
});
```
### Body Parsing
```typescript
app.post("/data", async (c) => {
// JSON body
const json = await c.req.json();
// Form data
const form = await c.req.parseBody();
// Raw text
const text = await c.req.text();
// Array buffer
const buffer = await c.req.arrayBuffer();
return c.json({ received: true });
});
```
### Response Methods
```typescript
// Text response
app.get("/text", (c) => c.text("Plain text"));
// JSON response
app.get("/json", (c) => c.json({ message: "Hello" }));
// HTML response
app.get("/html", (c) => c.html("<h1>Hello</h1>"));
// Custom status
app.get("/created", (c) => c.json({ id: 1 }, 201));
// Redirect
app.get("/old", (c) => c.redirect("/new"));
app.get("/permanent", (c) => c.redirect("/new", 301));
// Not found
app.get("/missing", (c) => c.notFound());
// Stream response
app.get("/stream", (c) => {
return c.streamText(async (stream) => {
await stream.write("Hello ");
await stream.write("World!");
});
});
```
### Headers and Status
```typescript
app.get("/custom", (c) => {
// Set response headers
c.header("X-Custom-Header", "value");
c.header("Cache-Control", "max-age=3600");
// Set status
c.status(201);
return c.json({ created: true });
});
// Response with headers inline
app.get("/inline", (c) => {
return c.json({ data: "value" }, 200, { "X-Custom": "header" });
});
```
### Context Variables
```typescript
// Set variables for downstream handlers
app.use(async (c, next) => {
c.set("userId", "user-123");
c.set("requestTime", Date.now());
await next();
});
app.get("/profile", (c) => {
const userId = c.get("userId");
const requestTime = c.get("requestTime");
return c.json({ userId, requestTime });
});
```
## Middleware
### Inline Middleware
```typescript
app.use(async (c, next) => {
console.log(`${c.req.method} ${c.req.path}`);
const start = Date.now();
await next();
const ms = Date.now() - start;
c.header("X-Response-Time", `${ms}ms`);
});
```
### Path-Specific Middleware
```typescript
// Apply to specific path
app.use("/api/*", async (c, next) => {
const auth = c.req.header("Authorization");
if (!auth) {
return c.json({ error: "Unauthorized" }, 401);
}
await next();
});
// Apply to specific method
app.use("/admin/*", "POST", async (c, next) => {
// Only runs for POST requests to /admin/*
await next();
});
```
### Middleware Factory Pattern
```typescript
const rateLimiter = (limit: number) => {
const requests = new Map<string, number>();
return async (c: Context, next: Next) => {
const ip = c.req.header("x-forwarded-for") ?? "unknown";
const count = requests.get(ip) ?? 0;
if (count >= limit) {
return c.json({ error: "Rate limited" }, 429);
}
requests.set(ip, count + 1);
await next();
};
};
app.use(rateLimiter(100));
```
### Built-in Middleware
```typescript
import { cors } from "hono/cors";
import { logger } from "hono/logger";
import { secureHeaders } from "hono/secure-headers";
import { compress } from "hono/compress";
import { etag } from "hono/etag";
import { basicAuth } from "hono/basic-auth";
import { bearerAuth } from "hono/bearer-auth";
import { csrf } from "hono/csrf";
import { timing } from "hono/timing";
// CORS
app.use(
cors({
origin: ["https://example.com"],
allowMethods: ["GET", "POST", "PUT", "DELETE"],
allowHeaders: ["Content-Type", "Authorization"],
credentials: true,
}),
);
// Logging
app.use(logger());
// Security headers
app.use(secureHeaders());
// Compression
app.use(compress());
// ETag caching
app.use(etag());
// Basic auth
app.use(
"/admin/*",
basicAuth({
username: "admin",
password: "secret",
}),
);
// Bearer token auth
app.use(
"/api/*",
bearerAuth({
token: "my-secret-token",
}),
);
// CSRF protection
app.use(csrf());
// Server timing
app.use(timing());
```
## Validation with Zod
### Setup
```bash
bun add @hono/zod-validator zod
```
### Request Validation
```typescript
import { zValidator } from "@hono/zod-validator";
import { z } from "zod";
const CreateUserSchema = z.object({
name: z.string().min(1),
email: z.string().email(),
age: z.number().int().positive().optional(),
});
app.post("/users", zValidator("json", CreateUserSchema), (c) => {
const data = c.req.valid("json");
// data is typed: { name: string; email: string; age?: number }
return c.json({ created: data });
});
```
### Multiple Validators
```typescript
const QuerySchema = z.object({
page: z.coerce.number().default(1),
limit: z.coerce.number().default(10),
});
const ParamSchema = z.object({
id: z.string().uuid(),
});
app.get(
"/users/:id",
zValidator("param", ParamSchema),
zValidator("query", QueryScRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.