diff --git a/packages/core/src/configuration/BaseConfigurator.ts b/packages/core/src/configuration/BaseConfigurator.ts index ae2543d0..95f2b4f5 100644 --- a/packages/core/src/configuration/BaseConfigurator.ts +++ b/packages/core/src/configuration/BaseConfigurator.ts @@ -14,6 +14,7 @@ import { IdentifierAliasTuple, IdentifierInstanceTuple } from "@aedart/contracts/container"; +import { shallowMerge } from "@aedart/support/objects"; import ConfigurationError from "../exceptions/ConfigurationError"; /** @@ -34,6 +35,15 @@ export default abstract class BaseConfigurator implements Configurator { */ protected app: Application | undefined; + /** + * Configuration items for the application + * + * @type {Record} + * + * @protected + */ + protected configurationItems: Record = {}; + /** * List of bindings to be registered * @@ -117,6 +127,32 @@ export default abstract class BaseConfigurator implements Configurator { return this; } + + /** + * Alias for {@see withConfiguration} + * + * @param {Record} items + * + * @return {this} + */ + public with(items: Record): this /* eslint-disable-line @typescript-eslint/no-explicit-any */ + { + return this.withConfiguration(items); + } + + /** + * Add configuration items for the application + * + * @param {Record} items + * + * @return {this} + */ + public withConfiguration(items: Record): this /* eslint-disable-line @typescript-eslint/no-explicit-any */ + { + this.configurationItems = shallowMerge(this.configurationItems, items); + + return this; + } /** * Add "core" bindings to be registered