---
title: Repo
---

```js
import {API} from "../components/config.js";
import {fieldRow} from "../components/field-help.js";
```

```js
const repoSlug = observable.params.slug;
const raw = await fetch(`${API}/repos/${repoSlug}/`)
  .then(r => r.ok ? r.json() : r.json().then(e => ({error: e.detail ?? `HTTP ${r.status}`})))
  .catch(e => ({error: String(e)}));
```

```js
if (raw.error) {
  display(html`<div style="color:red;padding:1rem">⚠️ ${raw.error}</div>`);
} else {
  const name = raw.name || raw.slug || repoSlug;
  display(html`<h1 style="font-size:1.1rem;margin-bottom:0.25rem">Repo · <em>${name}</em></h1>`);
  display(html`<p style="margin-top:0"><a href="/repos">← Repos</a> &nbsp;|&nbsp; <a href="/token-cost">← Token Cost</a></p>`);

  const FIELD_ORDER = [
    "id","slug","name","domain_slug","status","description",
    "local_path","remote_url","git_fingerprint",
    "sbom_source","last_sbom_at","last_state_synced_at",
    "created_at","updated_at",
  ];

  const rows = FIELD_ORDER.map(k => fieldRow(k, raw[k] ?? null));
  for (const k of Object.keys(raw)) {
    if (!FIELD_ORDER.includes(k)) rows.push(fieldRow(k, raw[k]));
  }

  display(html`<table style="border-collapse:collapse;width:100%;max-width:640px">
    <colgroup><col style="width:160px"><col></colgroup>
    <tbody>${rows}</tbody>
  </table>`);
}
```
