chore: initialize from frontend template 4dc033c

This commit is contained in:
DongHyeonka
2026-08-13 18:23:26 +09:00
commit 40107eec84
897 changed files with 234824 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
import { createApplication } from "../application/create-application.ts";
import type {
ApplicationApi,
ApplicationFeatureInputs,
} from "../application/ports/in/application-api.ts";
import type { ApplicationOutputPorts } from "../application/ports/out/application-output-ports.ts";
export type CompositionRoot<Config, Release, Infrastructure> = Readonly<{
config: Config;
release: Release;
infrastructure: Infrastructure;
application: ApplicationApi;
}>;
type AdapterBundle<Infrastructure> = Readonly<{
outputPorts: ApplicationOutputPorts;
infrastructure: Infrastructure;
featureInputs?: Readonly<Partial<ApplicationFeatureInputs>>;
}>;
type CompositionFactories<Config, Release, Infrastructure> = Readonly<{
loadConfig(): Promise<Config>;
loadRelease(config: Config): Promise<Release>;
createAdapters(context: Readonly<{
config: Config;
release: Release;
}>): Promise<AdapterBundle<Infrastructure>>;
}>;
/**
* This is the only module allowed to join concrete adapters to application
* ports. Boot phases are explicit so failures can stop before product mount.
*/
export async function createCompositionRoot<Config, Release, Infrastructure>(
factories: CompositionFactories<Config, Release, Infrastructure>,
): Promise<CompositionRoot<Config, Release, Infrastructure>> {
const config = await factories.loadConfig();
const release = await factories.loadRelease(config);
const adapters = await factories.createAdapters({ config, release });
const application = createApplication(
adapters.outputPorts,
adapters.featureInputs,
);
return Object.freeze({
config,
release,
infrastructure: adapters.infrastructure,
application,
});
}