24 lines
920 B
JavaScript
24 lines
920 B
JavaScript
import { createApplication } from "../application/create-application.js";
|
|
|
|
/**
|
|
* This is the only module allowed to join concrete adapters to application
|
|
* ports. Boot phases are explicit so failures can stop before product mount.
|
|
*
|
|
* @param {{
|
|
* loadConfig(): Promise<Record<string, unknown>>,
|
|
* loadRelease(config: Record<string, unknown>): Promise<Record<string, unknown>>,
|
|
* createAdapters(context: {
|
|
* config: Record<string, unknown>,
|
|
* release: Record<string, unknown>
|
|
* }): Promise<Parameters<typeof createApplication>[0]>
|
|
* }} factories
|
|
*/
|
|
export async function createCompositionRoot(factories) {
|
|
const config = await factories.loadConfig();
|
|
const release = await factories.loadRelease(config);
|
|
const ports = await factories.createAdapters({ config, release });
|
|
const application = createApplication(ports);
|
|
|
|
return Object.freeze({ config, release, ports, application });
|
|
}
|