41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/**
|
|
* Application facade factory. Concrete dependencies are supplied by bootstrap.
|
|
*
|
|
* @param {{
|
|
* resources: {
|
|
* query: import("./ports/resource-ports.js").ResourceQueryPort<unknown, unknown>,
|
|
* command: import("./ports/resource-ports.js").ResourceCommandPort<unknown, unknown>
|
|
* },
|
|
* cache: import("./ports/query-cache-port.js").QueryCachePort,
|
|
* storage: import("./ports/storage-port.js").StoragePort,
|
|
* telemetry: import("./ports/telemetry-port.js").TelemetryPort
|
|
* }} ports
|
|
*/
|
|
export function createApplication(ports) {
|
|
/**
|
|
* @param {unknown} query
|
|
* @param {import("./ports/resource-ports.js").RequestContext} [context]
|
|
*/
|
|
function queryResources(query, context) {
|
|
return ports.resources.query.execute(query, context);
|
|
}
|
|
|
|
/**
|
|
* @param {unknown} command
|
|
* @param {import("./ports/resource-ports.js").RequestContext} [context]
|
|
*/
|
|
function commandResources(command, context) {
|
|
return ports.resources.command.execute(command, context);
|
|
}
|
|
|
|
return Object.freeze({
|
|
resources: Object.freeze({
|
|
query: queryResources,
|
|
command: commandResources,
|
|
}),
|
|
cache: ports.cache,
|
|
storage: ports.storage,
|
|
telemetry: ports.telemetry,
|
|
});
|
|
}
|