Hono
Charge per call for Hono routes on Node, Bun, Deno, and Cloudflare Workers.
Pre-release · planned API
import { Hono } from "hono";
import { tollstile } from "@tollstile/hono";
import { toll } from "./toll";
const app = new Hono();
app.post(
"/v1/generate",
tollstile(toll.price("$0.04"), {
principal: (c) => (c.get("user") ? { id: c.get("user").id } : null),
}),
async (c) => {
const payment = c.get("payment"); // typed from your rails
return c.json(await generate(await c.req.json()));
},
);
export default app;| Option | Purpose |
|---|---|
principal | Resolves the authenticated caller for subscriber() and credits() |
- The resource name is
METHOD /route/:patternfrom Hono's matched route. - The handler succeeds when it returns a response below
400without throwing; otherwise the charge is released or refunded. - Receipt headers are appended to your response.