v3: api/ gets one layout rule and keeps to it, and whatever crosses the wire is defined once, in shared/ — api/model/interfaces.ts and src/model.ts declared the same 40 types by hand and had drifted: the error envelope, email required on one side and optional on the other, Invitee/InviteTreeEntry and LinkPreview/UrlPreviewResponse for one shape each. The validation limits, the role permissions, the chat length cap, the @mention pattern and the Bandcamp and YouTube player responses were copied too, behind "keep in sync" comments. shared/ now holds them once, one file per domain (api, category, chat, comment, dump, follow, mention, notification, permissions, player, playlist, search, user, validation, ws), and imports nothing from either half. The server sends Dates; the client reads Wire<T>, the same type with every Date an ISO string, and turns it back with src/utils/shared/deserialize.ts. APIErrorCode becomes a const object, since the frontend's erasableSyntaxOnly rejects an enum. The shared types showed two real gaps: the avatar upload and GET /api/users/me return the full self user and the frontend read them as public users, and a stored session may predate media tokens, so the client keeps it as its own Session type. The backend rule: each folder holds one kind of module, each file is named after its domain. routes/ parse and answer; services/ hold the logic and every SQL query (lib/auth.ts's token check moves to user-service); remote/ is the only place that fetches from other sites — the guarded fetch and the HTML scraping out of rich-content-service, public-address, the Bandcamp and YouTube resolvers, the link providers, the image proxy (fetch, checks and cache, out of routes/preview.ts) and the Twemoji glyphs (out of lib/site-icons.ts). model/ holds per table a row type, its guard and its mappers; validators/ the request guards; db/connection.ts the handle and transaction(), db/startup.ts the purges and default admin that db.ts ran on import, called at the same moment. Tests mirror the source one file per module, test/<layer>/<module>.test.ts, with shared/'s under shared/test/ (deno task test runs both); the test that covered the bandcamp and soundcloud providers together is two now, and the backend can() has its own, so 202 tests. deno lint src/ is clean too: window.* becomes globalThis.*, and test bodies and act() callbacks that never awaited lose their async. The README states the rule. No behaviour changes; the catalogues only move their source references.
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 50s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-09-27 20:19:48 +00:00
parent e9f6a1f23e
commit d392be7cb8
269 changed files with 6712 additions and 7122 deletions

View File

@@ -1,11 +1,8 @@
import { useEffect, useRef, useState } from "react";
import { Trans } from "@lingui/react/macro";
import { TextEditor, type TextEditorHandle } from "../editor/TextEditor.tsx";
import {
COUNT_FROM,
MAX_CHAT_LENGTH,
sendable,
} from "../../utils/chat/message.ts";
import { COUNT_FROM, sendable } from "../../utils/chat/message.ts";
import { VALIDATION } from "../../../shared/validation.ts";
export interface ChatEditBoxProps {
initial: string;
@@ -48,7 +45,7 @@ export function ChatEditBox({ initial, onSave, onCancel }: ChatEditBoxProps) {
onChange={setDraft}
rows={2}
autoResize
maxLength={MAX_CHAT_LENGTH}
maxLength={VALIDATION.CHAT_MESSAGE_MAX}
countFrom={COUNT_FROM}
className="comment-reply-textarea chat-input"
onSubmit={save}

View File

@@ -8,7 +8,7 @@ import { ConfirmModal } from "../shared/ConfirmModal.tsx";
import { Tooltip } from "../shared/Tooltip.tsx";
import { useHeightTransition } from "../../hooks/shared/useHeightTransition.ts";
import { relativeTime } from "../../utils/shared/relativeTime.ts";
import type { ChatMessage } from "../../model.ts";
import type { ChatMessage } from "../../../shared/chat.ts";
import { ChatEditBox } from "./ChatEditBox.tsx";
import { ReplyRef } from "./ReplyRef.tsx";
import { messageTextClass } from "../../utils/chat/message.ts";

View File

@@ -22,20 +22,14 @@ import type {
ChatReplyTarget,
PendingChatMessage,
} from "../../contexts/ws/WSContext.ts";
import {
type ChatMessage,
deserializeChatMessage,
type RawChatMessage,
} from "../../model.ts";
import type { ChatMessage } from "../../../shared/chat.ts";
import { deserializeChatMessage } from "../../utils/shared/deserialize.ts";
import type { Wire } from "../../../shared/api.ts";
import { ChatMessageItem } from "./ChatMessageItem.tsx";
import { PendingItem } from "./PendingItem.tsx";
import {
COUNT_FROM,
MAX_CHAT_LENGTH,
sendable,
snippet,
} from "../../utils/chat/message.ts";
import { COUNT_FROM, sendable, snippet } from "../../utils/chat/message.ts";
import { dayLabel, isSameDay } from "../../utils/chat/time.ts";
import { VALIDATION } from "../../../shared/validation.ts";
// Matches the server's default page size; a full page means there may be more.
const PAGE_SIZE = 50;
@@ -66,7 +60,7 @@ async function fetchChat(
const res = await authFetch(`${API_URL}/api/chat?${query}`);
const json = await res.json();
if (!json.success) throw new Error("chat fetch failed");
return (json.data as RawChatMessage[]).map(deserializeChatMessage);
return (json.data as Wire<ChatMessage>[]).map(deserializeChatMessage);
}
// Stream order, matching the server's: by time, then id to break ties.
@@ -814,7 +808,7 @@ export function ChatModal({ onClose }: { onClose: () => void }) {
placeholder={t`Type a message…`}
rows={2}
autoResize
maxLength={MAX_CHAT_LENGTH}
maxLength={VALIDATION.CHAT_MESSAGE_MAX}
countFrom={COUNT_FROM}
className="comment-reply-textarea chat-input"
onSubmit={handleSend}

View File

@@ -2,7 +2,7 @@ import { Trans } from "@lingui/react/macro";
import { Markdown } from "../editor/Markdown.tsx";
import { Avatar } from "../shared/Avatar.tsx";
import type { PendingChatMessage } from "../../contexts/ws/WSContext.ts";
import type { PublicUser } from "../../model.ts";
import type { PublicUser } from "../../../shared/user.ts";
import { ReplyRef } from "./ReplyRef.tsx";
import { messageTextClass } from "../../utils/chat/message.ts";

View File

@@ -1,7 +1,7 @@
import React from "react";
import { Controller, FormProvider } from "react-hook-form";
import { Trans } from "@lingui/react/macro";
import { VALIDATION } from "../../config/api.ts";
import { VALIDATION } from "../../../shared/validation.ts";
import { TextEditor, type TextEditorHandle } from "../editor/TextEditor.tsx";
import { FormError } from "../form/FormError.tsx";
import { SubmitButton } from "../form/SubmitButton.tsx";

View File

@@ -7,11 +7,11 @@ import { can } from "../../utils/auth/permissions.ts";
import type {
Comment,
CreateCommentRequest,
RawComment,
UpdateCommentRequest,
User,
} from "../../model.ts";
import { deserializeComment } from "../../model.ts";
} from "../../../shared/comment.ts";
import type { Wire } from "../../../shared/api.ts";
import type { SelfUser } from "../../../shared/user.ts";
import { deserializeComment } from "../../utils/shared/deserialize.ts";
import { Avatar } from "../shared/Avatar.tsx";
import { Markdown } from "../editor/Markdown.tsx";
import type { TextEditorHandle } from "../editor/TextEditor.tsx";
@@ -30,7 +30,7 @@ interface CommentNodeProps {
tree: Map<string, Comment[]>;
depth: number;
dumpId: string;
currentUser: User | null;
currentUser: SelfUser | null;
token: string | null;
onCommentCreated: (comment: Comment) => void;
onCommentDeleted: (commentId: string) => void;
@@ -71,7 +71,7 @@ export function CommentNode({
{ body, parentId: comment.id } satisfies CreateCommentRequest,
),
});
onCommentCreated(deserializeComment(await expectOk<RawComment>(res)));
onCommentCreated(deserializeComment(await expectOk<Wire<Comment>>(res)));
setReplyOpen(false);
}
@@ -98,7 +98,7 @@ export function CommentNode({
method: "PATCH",
body: JSON.stringify({ body } satisfies UpdateCommentRequest),
});
onCommentUpdated(deserializeComment(await expectOk<RawComment>(res)));
onCommentUpdated(deserializeComment(await expectOk<Wire<Comment>>(res)));
setEditOpen(false);
}

View File

@@ -2,13 +2,10 @@ import { useMemo } from "react";
import { t } from "@lingui/core/macro";
import { Plural, Trans } from "@lingui/react/macro";
import { API_URL } from "../../config/api.ts";
import type {
Comment,
CreateCommentRequest,
RawComment,
User,
} from "../../model.ts";
import { deserializeComment } from "../../model.ts";
import type { Comment, CreateCommentRequest } from "../../../shared/comment.ts";
import type { Wire } from "../../../shared/api.ts";
import type { SelfUser } from "../../../shared/user.ts";
import { deserializeComment } from "../../utils/shared/deserialize.ts";
import { Avatar } from "../shared/Avatar.tsx";
import { useAuth } from "../../hooks/auth/useAuth.ts";
import { expectOk } from "../../utils/shared/api.ts";
@@ -18,7 +15,7 @@ import { CommentNode } from "./CommentNode.tsx";
interface CommentThreadProps {
dumpId: string;
comments: Comment[];
currentUser: User | null;
currentUser: SelfUser | null;
token: string | null;
onCommentCreated: (comment: Comment) => void;
onCommentDeleted: (commentId: string) => void;
@@ -53,7 +50,7 @@ export function CommentThread({
method: "POST",
body: JSON.stringify({ body } satisfies CreateCommentRequest),
});
onCommentCreated(deserializeComment(await expectOk<RawComment>(res)));
onCommentCreated(deserializeComment(await expectOk<Wire<Comment>>(res)));
}
const visibleCount = comments.filter((c) => !c.deleted).length;

View File

@@ -1,7 +1,7 @@
import { memo } from "react";
import { Link } from "react-router";
import { Plural, Trans } from "@lingui/react/macro";
import type { Dump } from "../../model.ts";
import type { Dump } from "../../../shared/dump.ts";
import { relativeTime } from "../../utils/shared/relativeTime.ts";
import { dumpThumbnailUrl, dumpUrl } from "../../utils/shared/urls.ts";
import { useAuth } from "../../hooks/auth/useAuth.ts";

View File

@@ -1,5 +1,5 @@
import { useContext, useEffect, useState } from "react";
import type { Dump } from "../../model.ts";
import type { Dump } from "../../../shared/dump.ts";
import { formatBytes } from "../../utils/shared/format.ts";
import {
dumpFileUrl,

View File

@@ -1,7 +1,7 @@
import { memo } from "react";
import { Link } from "react-router";
import { Plural, Trans } from "@lingui/react/macro";
import type { Dump } from "../../model.ts";
import type { Dump } from "../../../shared/dump.ts";
import { relativeTime } from "../../utils/shared/relativeTime.ts";
import { dumpThumbnailUrl, dumpUrl } from "../../utils/shared/urls.ts";
import { useAuth } from "../../hooks/auth/useAuth.ts";

View File

@@ -1,6 +1,6 @@
import { useContext } from "react";
import { t } from "@lingui/core/macro";
import type { RichContent } from "../../model.ts";
import type { RichContent } from "../../../shared/dump.ts";
import { PlayerContext } from "../../contexts/player/PlayerContext.ts";
import {
canPlayRichContent,

View File

@@ -3,22 +3,25 @@ import { Link } from "react-router";
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { API_URL, VALIDATION } from "../../../config/api.ts";
import { API_URL } from "../../../config/api.ts";
import {
DUMP_MAX_FILE_SIZE_BYTES,
VALIDATION,
} from "../../../../shared/validation.ts";
import type {
CreateUrlDumpRequest,
Dump,
DumpUrlMatch,
PlaylistMembership,
RawDump,
RawDumpUrlMatch,
RawPlaylistMembership,
UrlPreviewResponse,
} from "../../../model.ts";
LinkPreview,
RichContent,
} from "../../../../shared/dump.ts";
import type { PlaylistMembership } from "../../../../shared/playlist.ts";
import type { Wire } from "../../../../shared/api.ts";
import {
deserializeDump,
deserializeDumpUrlMatch,
deserializePlaylistMembership,
} from "../../../model.ts";
} from "../../../utils/shared/deserialize.ts";
import { useAuth } from "../../../hooks/auth/useAuth.ts";
import { useWS } from "../../../hooks/ws/useWS.ts";
import { dumpUrl, normalizeUrl } from "../../../utils/shared/urls.ts";
@@ -30,9 +33,7 @@ import {
loadDumpDraft,
saveDumpDraft,
} from "../../../utils/dump/draft.ts";
import { MAX_FILE_SIZE } from "../../../config/upload.ts";
import { RichContentCard } from "../RichContentCard.tsx";
import type { RichContent } from "../../../model.ts";
import { Modal } from "../../shared/Modal.tsx";
import type { TextEditorHandle } from "../../editor/TextEditor.tsx";
import { CategorySelect } from "../../category/CategorySelect.tsx";
@@ -216,9 +217,7 @@ export function DumpCreateModal(
.then((res) => res.json())
.then((body) => {
if (signal.aborted) return;
const data = body.success
? body.data as UrlPreviewResponse
: undefined;
const data = body.success ? body.data as LinkPreview : undefined;
setUrlFetchState({
status: "done",
reached: data?.reached ?? false,
@@ -243,7 +242,7 @@ export function DumpCreateModal(
setDuplicateState({
url: canonicalUrl,
matches: body.success
? (body.data as RawDumpUrlMatch[]).map(deserializeDumpUrlMatch)
? (body.data as Wire<DumpUrlMatch>[]).map(deserializeDumpUrlMatch)
: [],
});
})
@@ -401,7 +400,7 @@ export function DumpCreateModal(
});
} else {
if (!title.trim()) throw new Error(t`Title is required.`);
if (file.size > MAX_FILE_SIZE) {
if (file.size > DUMP_MAX_FILE_SIZE_BYTES) {
throw new Error(t`File too large (max 50 MB).`);
}
const formData = new FormData();
@@ -422,7 +421,7 @@ export function DumpCreateModal(
}
}
const dump = deserializeDump(await expectOk<RawDump>(res));
const dump = deserializeDump(await expectOk<Wire<Dump>>(res));
clearDumpDraft();
injectDump(dump);
setCreatedDump(dump);
@@ -433,7 +432,7 @@ export function DumpCreateModal(
.then((body) => {
if (body.success) {
setMemberships(
(body.data as RawPlaylistMembership[]).map(
(body.data as Wire<PlaylistMembership>[]).map(
deserializePlaylistMembership,
),
);

View File

@@ -1,6 +1,6 @@
import { Link } from "react-router";
import { Plural, Trans } from "@lingui/react/macro";
import type { DumpUrlMatch } from "../../../model.ts";
import type { DumpUrlMatch } from "../../../../shared/dump.ts";
import { dumpUrl } from "../../../utils/shared/urls.ts";
import { relativeTime } from "../../../utils/shared/relativeTime.ts";

View File

@@ -2,7 +2,7 @@ import { useRef } from "react";
import type { UseFormRegisterReturn } from "react-hook-form";
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { VALIDATION } from "../../../config/api.ts";
import { VALIDATION } from "../../../../shared/validation.ts";
/**
* Title row shared by both kinds of dump: the suggested title (scraped from the

View File

@@ -3,7 +3,8 @@ import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { DumpCard } from "../dump/DumpCard.tsx";
import { ErrorCard } from "../shared/ErrorCard.tsx";
import type { Dump, User } from "../../model.ts";
import type { Dump } from "../../../shared/dump.ts";
import type { SelfUser } from "../../../shared/user.ts";
import { hotScore } from "../../utils/feed/hotScore.ts";
// What the index hands whichever main feed its tab shows.
@@ -16,7 +17,7 @@ export interface MainFeedProps {
sentinelRef: Ref<HTMLDivElement>;
voteCounts: Record<string, number>;
myVotes: Set<string>;
user: User | null;
user: SelfUser | null;
castVote: (id: string, shownCount?: number) => void;
removeVote: (id: string, shownCount?: number) => void;
}

View File

@@ -12,12 +12,11 @@ import { useInfiniteScroll } from "../../hooks/feed/useInfiniteScroll.ts";
import { useScrollSave } from "../../hooks/feed/useScrollSave.ts";
import {
deserializeDump,
type Dump,
hydrateDump,
type PaginatedData,
type RawDump,
type User,
} from "../../model.ts";
} from "../../utils/shared/deserialize.ts";
import type { Dump } from "../../../shared/dump.ts";
import type { PaginatedData, Wire } from "../../../shared/api.ts";
import type { SelfUser } from "../../../shared/user.ts";
import { friendlyFetchError } from "../../utils/shared/api.ts";
type FeedState =
@@ -33,12 +32,12 @@ type FeedState =
/** Page of a followed feed. Throws the server's own message on an error
* envelope, so it isn't mistaken for a lost connection. */
async function readPage(res: Response): Promise<PaginatedData<RawDump>> {
async function readPage(res: Response): Promise<PaginatedData<Wire<Dump>>> {
const body = await res.json();
if (!body.success) {
throw new Error(body.error?.message ?? `HTTP ${res.status}`);
}
return body.data as PaginatedData<RawDump>;
return body.data as PaginatedData<Wire<Dump>>;
}
type FollowedSection = "users" | "playlists";
@@ -47,7 +46,7 @@ interface FollowedFeedProps {
categorySlug?: string;
voteCounts: Record<string, number>;
myVotes: Set<string>;
user: User;
user: SelfUser;
castVote: (id: string, shownCount?: number) => void;
removeVote: (id: string, shownCount?: number) => void;
deletedDumpIds: Set<string>;
@@ -59,7 +58,7 @@ interface FollowedSubFeedProps {
state: FeedState;
voteCounts: Record<string, number>;
myVotes: Set<string>;
user: User;
user: SelfUser;
castVote: (id: string, shownCount?: number) => void;
removeVote: (id: string, shownCount?: number) => void;
deletedDumpIds: Set<string>;

View File

@@ -26,7 +26,7 @@ interface SearchEntryState {
/** React Router's index of the current history entry — 0 for the first page
* of the session, which has nothing in the app to go back to. */
function historyIndex(): number {
return (window.history.state as { idx?: number } | null)?.idx ?? 0;
return (globalThis.history.state as { idx?: number } | null)?.idx ?? 0;
}
export function AppHeader(

View File

@@ -3,9 +3,9 @@ import { Link } from "react-router";
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { Avatar } from "../shared/Avatar.tsx";
import type { User } from "../../model.ts";
import type { SelfUser } from "../../../shared/user.ts";
export function UserMenu({ user }: { user: User }) {
export function UserMenu({ user }: { user: SelfUser }) {
const [open, setOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null);

View File

@@ -2,8 +2,9 @@ import { useEffect, useState } from "react";
import { t } from "@lingui/core/macro";
import { API_URL } from "../../config/api.ts";
import { useAuth } from "../../hooks/auth/useAuth.ts";
import type { PlaylistMembership, RawPlaylistMembership } from "../../model.ts";
import { deserializePlaylistMembership } from "../../model.ts";
import type { PlaylistMembership } from "../../../shared/playlist.ts";
import type { Wire } from "../../../shared/api.ts";
import { deserializePlaylistMembership } from "../../utils/shared/deserialize.ts";
import { Modal } from "../shared/Modal.tsx";
import { PlaylistMembershipPanel } from "./PlaylistMembershipPanel.tsx";
@@ -25,7 +26,7 @@ export function AddToPlaylistModal(
.then((body) => {
if (body.success) {
setMemberships(
(body.data as RawPlaylistMembership[]).map(
(body.data as Wire<PlaylistMembership>[]).map(
deserializePlaylistMembership,
),
);

View File

@@ -1,7 +1,7 @@
import { useState } from "react";
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import type { Playlist } from "../../model.ts";
import type { Playlist } from "../../../shared/playlist.ts";
import { Modal } from "../shared/Modal.tsx";
import { PlaylistCreateForm } from "./PlaylistCreateForm.tsx";

View File

@@ -1,7 +1,7 @@
import { Link, useNavigate } from "react-router";
import { t } from "@lingui/core/macro";
import { Plural, Trans } from "@lingui/react/macro";
import type { Playlist } from "../../model.ts";
import type { Playlist } from "../../../shared/playlist.ts";
import { relativeTime } from "../../utils/shared/relativeTime.ts";
import { playlistImageUrl, playlistUrl } from "../../utils/shared/urls.ts";
import {

View File

@@ -1,12 +1,13 @@
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { API_URL, VALIDATION } from "../../config/api.ts";
import { API_URL } from "../../config/api.ts";
import { VALIDATION } from "../../../shared/validation.ts";
import type {
CreatePlaylistRequest,
Playlist,
RawPlaylist,
} from "../../model.ts";
import { deserializePlaylist } from "../../model.ts";
} from "../../../shared/playlist.ts";
import type { Wire } from "../../../shared/api.ts";
import { deserializePlaylist } from "../../utils/shared/deserialize.ts";
import { useAuth } from "../../hooks/auth/useAuth.ts";
import { expectOk } from "../../utils/shared/api.ts";
import { FormActions } from "../form/FormActions.tsx";
@@ -42,7 +43,7 @@ export function PlaylistCreateForm(
const onSubmit = form.submit(async ({ title, description, isPublic }) => {
const playlist = deserializePlaylist(
await expectOk<RawPlaylist>(
await expectOk<Wire<Playlist>>(
await authFetch(`${API_URL}/api/playlists`, {
method: "POST",
headers: { "Content-Type": "application/json" },

View File

@@ -1,6 +1,6 @@
import { useState } from "react";
import { Trans } from "@lingui/react/macro";
import type { PlaylistMembership } from "../../model.ts";
import type { PlaylistMembership } from "../../../shared/playlist.ts";
import { PlaylistCreateForm } from "./PlaylistCreateForm.tsx";
interface PlaylistMembershipPanelProps {

View File

@@ -1,7 +1,8 @@
import { useState } from "react";
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { API_URL, VALIDATION } from "../../config/api.ts";
import { API_URL } from "../../config/api.ts";
import { VALIDATION } from "../../../shared/validation.ts";
import { useAuth } from "../../hooks/auth/useAuth.ts";
import { Modal } from "../shared/Modal.tsx";
import { expectOk } from "../../utils/shared/api.ts";

View File

@@ -1,6 +1,6 @@
import type { ReactNode } from "react";
import { Link } from "react-router";
import type { PublicUser } from "../../model.ts";
import type { PublicUser } from "../../../shared/user.ts";
import { Avatar } from "../shared/Avatar.tsx";
interface ProfileSubpageHeaderProps {

View File

@@ -6,13 +6,10 @@ import { Trans } from "@lingui/react/macro";
import { Avatar } from "../shared/Avatar.tsx";
import { useAuth } from "../../hooks/auth/useAuth.ts";
import { DEFAULT_PAGE_SIZE } from "../../config/api.ts";
import {
deserializePublicUser,
type PaginatedData,
parseAPIResponse,
type PublicUser,
type RawPublicUser,
} from "../../model.ts";
import { deserializePublicUser } from "../../utils/shared/deserialize.ts";
import type { PaginatedData, Wire } from "../../../shared/api.ts";
import { parseAPIResponse } from "../../utils/shared/api.ts";
import type { PublicUser } from "../../../shared/user.ts";
interface UserListPopoverProps {
anchorRef: React.RefObject<HTMLElement | null>;
@@ -121,7 +118,7 @@ export function UserListPopover(
})
.then((r) => r.json())
.then((body) => {
const apiResponse = parseAPIResponse<PaginatedData<RawPublicUser>>(
const apiResponse = parseAPIResponse<PaginatedData<Wire<PublicUser>>>(
body,
);
if (!apiResponse.success) {
@@ -152,7 +149,7 @@ export function UserListPopover(
})
.then((r) => r.json())
.then((body) => {
const apiResponse = parseAPIResponse<PaginatedData<RawPublicUser>>(
const apiResponse = parseAPIResponse<PaginatedData<Wire<PublicUser>>>(
body,
);
setState((prev) => {