Add --url flag to ccc-client and ccc-queue

Overrides CONDUIT_URL env var. Resolved through load_client_config and
threaded into create_conduit_client as base_url parameter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 21:20:59 +00:00
parent 0d1e25019e
commit 62d2480cd4
5 changed files with 32 additions and 23 deletions

View File

@@ -3,16 +3,16 @@
import { sign_request } from "./auth.mjs";
const BASE_URL = process.env.CONDUIT_URL || "http://localhost:3015";
const DEFAULT_URL = 'http://localhost:3015';
export function create_conduit_client(username, secret) {
export function create_conduit_client(username, secret, base_url = process.env.CONDUIT_URL || DEFAULT_URL) {
function auth_headers(body_string) {
return sign_request(secret, username, body_string);
}
async function call_action(action, params = {}) {
const body_string = JSON.stringify({ action, ...params });
const res = await fetch(`${BASE_URL}/action`, {
const res = await fetch(`${base_url}/action`, {
method: "POST",
headers: { "Content-Type": "application/json", ...auth_headers(body_string) },
body: body_string,
@@ -25,14 +25,14 @@ export function create_conduit_client(username, secret) {
}
async function get_queue() {
const res = await fetch(`${BASE_URL}/queue`, {
const res = await fetch(`${base_url}/queue`, {
headers: auth_headers(''),
});
return res.json();
}
async function resolve_queue_item(id, decision) {
const res = await fetch(`${BASE_URL}/queue/${id}/${decision}`, {
const res = await fetch(`${base_url}/queue/${id}/${decision}`, {
method: 'POST',
headers: auth_headers(''),
});