ts / dist / esm / tunnels.js
218 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { checkGate } from './gate.js';
import * as http from './http.js';
/** GET /tunnels — List your tunnels. */
export const list = (client) => http.get(client, '/tunnels');
/** POST /tunnels — Create a tunnel. Gated on `hostname`. */
export const create = async (client, body) => {
    await checkGate(client, 'POST /tunnels', { domain: body.hostname });
    return http.post(client, '/tunnels', { body });
};
/** GET /tunnels/{id} — Tunnel detail. */
export const get = (client, id) => http.get(client, '/tunnels/{id}', { params: { id } });
/** Resolve the tunnel's hostname (only when gated) and run the gate. */
const checkTunnelGate = async (client, op, id) => {
    if (!client.gate)
        return;
    const { tunnel } = await get(client, id);
    await checkGate(client, op, { domain: tunnel?.hostname });
};
/** DELETE /tunnels/{id} — Delete a tunnel (billing stops). */
export const remove = async (client, id, body) => {
    await checkTunnelGate(client, 'DELETE /tunnels/{id}', id);
    return http.del(client, '/tunnels/{id}', { params: { id }, body });
};
/** PATCH /tunnels/{id} — Update tunnel settings. */
export const update = async (client, id, body) => {
    await checkTunnelGate(client, 'PATCH /tunnels/{id}', id);
    return http.patch(client, '/tunnels/{id}', { params: { id }, body });
};
/** POST /tunnels/{id}/verify-dns — Re-check DNS. */
export const verifyDns = (client, id) => http.post(client, '/tunnels/{id}/verify-dns', { params: { id } });

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/ts.git