feat: validate runtime configuration before mount

This commit is contained in:
donghyeon-ka
2026-07-25 20:46:06 +09:00
parent 7199d7d9b6
commit 6b51104010
8 changed files with 356 additions and 8 deletions
+36 -7
View File
@@ -1,11 +1,24 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
function BootstrapShell() {
import { BootConfigError, loadRuntimeConfig } from "./load-runtime-config.js";
/** @param {{ environment: string }} props */
function BootstrapShell({ environment }) {
return (
<main>
<h1>Clean Architecture Frontend</h1>
<p>런타임 계약 불러오는 중입니다.</p>
<p>{environment} 런타임 계약 검증되었습니다.</p>
</main>
);
}
/** @param {{ supportReference: string }} props */
function BootErrorShell({ supportReference }) {
return (
<main role="alert">
<h1>애플리케이션을 시작할 없습니다.</h1>
<p>지원 참조: {supportReference}</p>
</main>
);
}
@@ -16,8 +29,24 @@ if (!rootElement) {
throw new Error("Missing #root mount element");
}
createRoot(rootElement).render(
<StrictMode>
<BootstrapShell />
</StrictMode>,
);
const root = createRoot(rootElement);
async function boot() {
try {
const runtime = await loadRuntimeConfig();
root.render(
<StrictMode>
<BootstrapShell environment={runtime.config.APP_ENV} />
</StrictMode>,
);
} catch (error) {
const supportReference =
error instanceof BootConfigError
? error.safe.supportReference
: "boot:unknown";
root.render(<BootErrorShell supportReference={supportReference} />);
}
}
void boot();