unslopkit

Components / Code blocks

Collapsible JSON

A JSON payload where every object and array folds, with key counts when closed, indent guides, and the selected value's path at the bottom.

job-sheet.json1.2 kB
{ 7 keys }
"id": "JS-2207",
"site": "14 Alder St",
"signed_off": true,
"crew": [ 2 items ],
"Ines Ortega",
"Dana Whitfield"
],
"hours": { 3 keys },
"labor": 22.5,
"travel": 1.5,
"overtime": 0
},
"materials": [ 2 items ],
{ 3 keys },
"sku": "OAK-WT-30",
"qty": 1,
"unit_cost": 41800
},
{ 3 keys }
"sku": "2x6-PT-12",
"qty": 40,
"unit_cost": 1145
}
],
"invoice": null
}

Path$.materials[1].qty

Drawn in your kit, Plain.Change the look

The code

Plain HTML and CSS on your kit's variables. Put it next to tokens/variables.css from your kit's files and it draws in your look.

<div class="ukc-code-json-viewer">
<div class="jv">
  <div class="hd"><span class="fn"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H6v18h12V7z"/><path d="M14 3v4h4"/></svg>job-sheet.json</span><span class="sz">1.2 kB</span></div>
  <div class="body">
    <details open><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>{<span class="cnt"> 7 keys }</span></summary>
      <div class="kids">
        <div class="row"><span class="key">"id"</span>: <span class="s">"JS-2207"</span>,</div>
        <div class="row"><span class="key">"site"</span>: <span class="s">"14 Alder St"</span>,</div>
        <div class="row"><span class="key">"signed_off"</span>: <span class="k">true</span>,</div>
        <details open><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg><span class="key">"crew"</span>: [<span class="cnt"> 2 items ],</span></summary>
          <div class="kids">
            <div class="row"><span class="s">"Ines Ortega"</span>,</div>
            <div class="row"><span class="s">"Dana Whitfield"</span></div>
          </div>
          <div class="row">],</div>
        </details>
        <details><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg><span class="key">"hours"</span>: {<span class="cnt"> 3 keys },</span></summary>
          <div class="kids">
            <div class="row"><span class="key">"labor"</span>: <span class="n">22.5</span>,</div>
            <div class="row"><span class="key">"travel"</span>: <span class="n">1.5</span>,</div>
            <div class="row"><span class="key">"overtime"</span>: <span class="n">0</span></div>
          </div>
          <div class="row">},</div>
        </details>
        <details open><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg><span class="key">"materials"</span>: [<span class="cnt"> 2 items ],</span></summary>
          <div class="kids">
            <details><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>{<span class="cnt"> 3 keys },</span></summary>
              <div class="kids">
                <div class="row"><span class="key">"sku"</span>: <span class="s">"OAK-WT-30"</span>,</div>
                <div class="row"><span class="key">"qty"</span>: <span class="n">1</span>,</div>
                <div class="row"><span class="key">"unit_cost"</span>: <span class="n">41800</span></div>
              </div>
              <div class="row">},</div>
            </details>
            <details open><summary><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>{<span class="cnt"> 3 keys }</span></summary>
              <div class="kids">
                <div class="row"><span class="key">"sku"</span>: <span class="s">"2x6-PT-12"</span>,</div>
                <div class="row sel" aria-current="true"><span class="key">"qty"</span>: <span class="n">40</span>,</div>
                <div class="row"><span class="key">"unit_cost"</span>: <span class="n">1145</span></div>
              </div>
              <div class="row">}</div>
            </details>
          </div>
          <div class="row">],</div>
        </details>
        <div class="row"><span class="key">"invoice"</span>: <span class="k">null</span></div>
      </div>
      <div class="row">}</div>
    </details>
  </div>
  <p class="path"><span class="lbl">Path</span><code>$.materials[1].qty</code><button class="ib" type="button" aria-label="Copy path"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="8" y="8" width="12" height="12" rx="1"/><path d="M16 8V4H4v12h4"/></svg></button></p>
</div>
</div>

More code blocks

All 24
  • Step 3Handle the webhook

    export async function POST(req: Request) {
      const raw = await req.text();
      const event = verify(raw, req.headers); (note 1)
     
      if (event.type === "invoice.paid") { (note 2)
        await markPaid(event.invoice);
      }
      return new Response(null, { status: 204 }); (note 3)
    }
    1. Note 1: verify throws if the signature or timestamp is off, so a forged call never reaches your code.

    2. Note 2: Check the type first. New event types get added, so skip the ones you don't handle.

    3. Note 3: Answer within 10 seconds. Slow or failed deliveries are retried for three days.

    Annotated snippet

  • src/jobs/sheet.ts TS 21 lines · 418 B Raw
    export type JobSheet = {
      id: string;
      site: string;
      crew: string[];
      hours: Array<Hours>;
      materials: Array<Material>;
      signedOffBy?: string;
      status: "open" | "signed" | "invoiced";
    };
    Show 12 more linesShow fewer lines
     
    export type Hours = {
      who: string;
      day: string; // ISO date
      hours: number;
    };
     
    export type Material = {
      sku: string;
      qty: number;
      unitCost: number; // in cents
    };

    File with show more

  • UnhandledPOST /v2/invoicesstaging

    TypeError: Cannot read properties of undefined (reading 'rate')

    1. lineTotalsrc/totals.ts:15:23
      export function lineTotal(l: Line) {
        const price = PRICES[l.sku];
        return l.qty * price.rate;
                       ^^^^^ price is undefined
      }
    2. buildInvoicesrc/invoices.ts:42:18
        for (const line of sheet.lines) {
          totals.push(lineTotal(line));
        }
    3. POSTapp/api/invoices/route.ts:18:9
        const sheet = await getSheet(body.job);
        const draft = buildInvoice(sheet);
    4. 3 frames in node_modules
      • handle @halden/sdk/dist/http.js:88:11
      • dispatch router-lite/index.js:41:7
      • run router-lite/index.js:12:3
    Seen 3 times in the last hour

    Error with stack trace

  • .env.local4 of 5 set
    1. # Halden, test mode
    2. HALDEN_API_KEY=hidden, ends in 4f9chld_test_8Kq2Vn5x4f9c
    3. HALDEN_ENV=test
    4. DB_PASSWORD=hiddenlocal-dev-only
    5. # Webhooks
    6. HALDEN_WEBHOOK_SECRET=

      Empty Webhook checks fail until this is set. Copy it from Settings, then Webhooks.

    Env file with reveal

  • unpaid.sql
    -- Unpaid and past due, oldest first
    SELECT j.code, c.name, i.total,
      current_date - i.due_on AS late
    FROM invoices i
    JOIN jobs j ON j.id = i.job_id
    JOIN clients c ON c.id = j.client_id
    WHERE i.paid_at IS NULL
      AND i.due_on < current_date
    ORDER BY late DESC;

    4 rows in 18 msExport CSV

    codenametotallate
    JS-2216Pier Ln Holdings6,900.0021
    JS-2207Reyes Framing2,140.009
    JS-2219Mill Lane Lofts1,212.504
    JS-2223O. Whitaker480.001

    Query and result

  • Guides · API keys

    Rotate a key without downtime

    Run halden keys rotate in your project folder. The old key keeps working for 24 hours, so a deploy that still reads HALDEN_KEY won't fail halfway.

    The CLI writes the new key to ~/.halden/config.toml. Rather click than type? Press Ctrl K in the dashboard and search for keys.

    Shortcuts in the docs

    Search the docs
    /
    Copy the focused snippet
    C
    Next or previous heading
    JK

    Inline code and keys