Skip to content

refactor(dashboard): extract api()/TOKEN/MODE → src/lib/api.ts#32

Merged
esengine merged 1 commit into
mainfrom
refactor/dashboard-extract-api
May 1, 2026
Merged

refactor(dashboard): extract api()/TOKEN/MODE → src/lib/api.ts#32
esengine merged 1 commit into
mainfrom
refactor/dashboard-extract-api

Conversation

@esengine

@esengine esengine commented May 1, 2026

Copy link
Copy Markdown
Owner

Stage 3 of #28, PR 3.1. Pulls the fetch wrapper (token-on-url for reads, header-too for mutations, JSON parsing, structured ApiError) into a typed leaf module. Used by every panel, no Preact dependency.

Net: dashboard/app.js loses ~30 LoC, dashboard/src/lib/api.ts (new) replaces it with named typed exports (TOKEN, MODE, ApiOptions, ApiError, api<T>()).

Bundle output unchanged byte-wise (esbuild inlines as before). 1682/1682 tests pass.

Closes part of #28.

Stage 3 of #28, PR 3.1. The fetch wrapper (token-on-url for reads,
header-too for mutations, JSON parsing, structured ApiError) was
the next leaf-y piece after the formatters. Used by every panel,
no Preact dependency, easy to type.

- dashboard/src/lib/api.ts (new) — typed exports: TOKEN, MODE
  ("standalone" | "attached"), ApiOptions, ApiError, api<T>().
- dashboard/app.js — drops the inline definitions (~30 lines),
  imports the named exports.

Bundle still passes through tsup unchanged at the byte level
(esbuild inlines the lib module into a single file as before).
1682/1682 tests still pass.
@esengine esengine added the enhancement New feature or request label May 1, 2026
@esengine esengine merged commit a5f4c19 into main May 1, 2026
2 checks passed
@esengine esengine deleted the refactor/dashboard-extract-api branch May 1, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant