feat(settings): add browser setup and administration (#10)

This commit is contained in:
Florian Schmidt
2026-11-16 10:15:04 +01:00
parent 4fe7e4e376
commit 02a22bef40
20 changed files with 939 additions and 24 deletions
+31
View File
@@ -0,0 +1,31 @@
import type {
SetupStatusResponse,
SetupRequest,
ChangePasswordRequest,
SessionSettingsResponse,
ClaudeStatusResponse,
SystemInfoResponse,
} from "@shellbook/core";
import { HttpError } from "./api";
async function request<T>(path: string, body?: unknown): Promise<T> {
const response = await fetch(`/api${path}`, {
method: body === undefined ? "GET" : "POST",
credentials: "same-origin",
headers: body === undefined ? {} : { "Content-Type": "application/json" },
body: body === undefined ? undefined : JSON.stringify(body),
});
if (!response.ok) throw new HttpError(response.status);
return response.status === 204
? (undefined as T)
: (response.json() as Promise<T>);
}
export const settingsApi = {
setupStatus: () => request<SetupStatusResponse>("/auth/setup"),
setup: (body: SetupRequest) => request<void>("/auth/setup", body),
password: (body: ChangePasswordRequest) =>
request<void>("/settings/password", body),
revoke: () => request<void>("/settings/sessions/revoke", {}),
session: () => request<SessionSettingsResponse>("/settings/session"),
claude: () => request<ClaudeStatusResponse>("/settings/claude"),
system: () => request<SystemInfoResponse>("/settings/system"),
};