A simple, zero-configuration script to quickly boot FreeBSD ISO images using QEMU

feat: add port option to HTTP API server for configurable listening port

Changed files
+9 -3
src
api
+1
main.ts
··· 400 400 ) 401 401 .description("Manage volumes") 402 402 .command("serve", "Start the FreeBSD-Up HTTP API server") 403 + .option("-p, --port <port:number>", "Port to listen on", { default: 8890 }) 403 404 .action(() => { 404 405 serve(); 405 406 })
+8 -3
src/api/mod.ts
··· 5 5 import { logger } from "hono/logger"; 6 6 import { cors } from "hono/cors"; 7 7 import { bearerAuth } from "hono/bearer-auth"; 8 + import { parseFlags } from "@cliffy/flags"; 8 9 9 10 export default function () { 10 11 const token = Deno.env.get("FREEBSD_UP_API_TOKEN") || 11 12 crypto.randomUUID(); 13 + const { flags } = parseFlags(Deno.args); 12 14 13 15 if (!Deno.env.get("FREEBSD_UP_API_TOKEN")) { 14 16 console.log(`Using API token: ${token}`); ··· 31 33 app.route("/machines", machines); 32 34 app.route("/volumes", volumes); 33 35 34 - const port = Deno.env.get("FREEBSD_UP_PORT") 35 - ? Number(Deno.env.get("FREEBSD_UP_PORT")) 36 - : 8890; 36 + const port = Number( 37 + flags.port || flags.p || 38 + (Deno.env.get("FREEBSD_UP_PORT") 39 + ? Number(Deno.env.get("FREEBSD_UP_PORT")) 40 + : 8890), 41 + ); 37 42 38 43 Deno.serve({ port }, app.fetch); 39 44 }