latest
pomdtr/smallweb.runWorks with
•JSR Score52%•It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




Publisheda year ago (0.2.1)
Cli adapter for http framework
Usage with Hono
Conventions:
- commands use the
RUNmethod - positional arguments are passed as path parameters
- flags are passed as query parameters
- boolean flags are passed as
?flag - flags with values are passed as
?flag=value - repeated flags are passed as
?flag=value1&flag=value2
- boolean flags are passed as
- stdin is passed as body
- the response is printed to stdout if the request is successful, otherwise it is printed to stderr
Examples:
dump app --json->RUN /dump/app?json
import { Hono } from "npm:hono" import { HttpCli } from "jsr:@pomdtr/http-cli" import { zValidator } from 'npm:@hono/zod-validator' import { z } from 'npm:zod' const app = new Hono() app.on("RUN", "/hello/:name?", zValidator("query", z.object({ help: z.string().optional().describe("Show help"), })), (c) => { const flags = c.req.valid("query") if (flags.help) { return c.text("Usage: hello [name]") } const { name = "World" } = c.req.param() return c.text(`Hello, ${name}!`) }) // create a cli instance const cli = new HttpCli(app.fetch) // run the cli (args are optional, defaults to Deno.args) await cli.run()
$ deno run main.ts hello pomdtr Hello, pomdtr!
Add Package
deno add jsr:@pomdtr/http-cli
Import symbol
import * as http_cli from "@pomdtr/http-cli";
Import directly with a jsr specifier
import * as http_cli from "jsr:@pomdtr/http-cli";
Add Package
pnpm i jsr:@pomdtr/http-cli
pnpm dlx jsr add @pomdtr/http-cli
Import symbol
import * as http_cli from "@pomdtr/http-cli";
Add Package
yarn add jsr:@pomdtr/http-cli
yarn dlx jsr add @pomdtr/http-cli
Import symbol
import * as http_cli from "@pomdtr/http-cli";
Add Package
vlt install jsr:@pomdtr/http-cli
Import symbol
import * as http_cli from "@pomdtr/http-cli";
Add Package
npx jsr add @pomdtr/http-cli
Import symbol
import * as http_cli from "@pomdtr/http-cli";
Add Package
bunx jsr add @pomdtr/http-cli
Import symbol
import * as http_cli from "@pomdtr/http-cli";