Run a SQL request from Node.js
A Node.js application can use the documented HTTP interface without a database-specific package. Send SQL with POST, check the response status and select an output format that the application can parse.
const endpoint = process.env.COORDINATOR_HTTP_URL;
const user = process.env.COORDINATOR_USER;
const password = process.env.COORDINATOR_PASSWORD;
if (!endpoint || !user || password === undefined) throw new Error('Missing connection configuration');
const response = await fetch(endpoint, {
method: 'POST',
headers: {
Authorization: `Basic ${Buffer.from(`${user}:${password}`).toString('base64')}`,
},
body: 'SELECT 1 AS value FORMAT json_each_row',
});
const body = await response.text();
if (!response.ok) throw new Error(`SQL HTTP ${response.status}: ${body}`);
console.log(JSON.parse(body));Keep the request contract visible
The example sends a fixed query and parses one returned row. For several json_each_row rows, parse each nonempty line separately. Do not concatenate untrusted input into SQL: HTTP bound parameters are unsupported. Encode uploaded values using a supported input format and keep schema choices under application control.
Use HTTPS through external TLS termination or a trusted route; the server itself has no TLS listener. Save X-Coordinator-Query-Id for diagnostics, redact secrets from errors, and reconcile an ambiguous write before retrying it. Each HTTP request has a separate session.
See HTTP interface and JSON row format.