feat: Flatten the provider config for all modules (#7930)

This commit is contained in:
Stevche Radevski
2024-07-03 16:57:12 +02:00
committed by GitHub
parent b6e4435c23
commit 012a624ee4
24 changed files with 168 additions and 292 deletions
+13 -12
View File
@@ -8,20 +8,21 @@ import {
import { Lifetime, asFunction, asValue } from "awilix"
const registrationFn = async (klass, container, pluginOptions) => {
Object.entries(pluginOptions.config || []).map(([name, config]) => {
const key = FileProviderService.getRegistrationIdentifier(klass, name)
const key = FileProviderService.getRegistrationIdentifier(
klass,
pluginOptions.id
)
container.register({
[FileProviderRegistrationPrefix + key]: asFunction(
(cradle) => new klass(cradle, config),
{
lifetime: klass.LIFE_TIME || Lifetime.SINGLETON,
}
),
})
container.registerAdd(FileProviderIdentifierRegistrationName, asValue(key))
container.register({
[FileProviderRegistrationPrefix + key]: asFunction(
(cradle) => new klass(cradle, pluginOptions.options ?? {}),
{
lifetime: klass.LIFE_TIME || Lifetime.SINGLETON,
}
),
})
container.registerAdd(FileProviderIdentifierRegistrationName, asValue(key))
}
export default async ({