feat: Flatten the provider config for all modules (#7930)
This commit is contained in:
1 parent
b6e4435c23
commit
012a624ee4
24 files changed
+168
-292
No files matched your search
@@ -10,20 +10,21 @@ import { FulfillmentIdentifiersRegistrationName } from "@types"
|
||||
import { Lifetime, asFunction, asValue } from "awilix"
|
||||
|
||||
const registrationFn = async (klass, container, pluginOptions) => {
|
||||
Object.entries(pluginOptions.config || []).map(([name, config]) => {
|
||||
const key = FulfillmentProviderService.getRegistrationIdentifier(
|
||||
klass,
|
||||
name
|
||||
)
|
||||
const key = FulfillmentProviderService.getRegistrationIdentifier(
|
||||
klass,
|
||||
pluginOptions.id
|
||||
)
|
||||
|
||||
container.register({
|
||||
["fp_" + key]: asFunction((cradle) => new klass(cradle, config), {
|
||||
container.register({
|
||||
["fp_" + key]: asFunction(
|
||||
(cradle) => new klass(cradle, pluginOptions.options),
|
||||
{
|
||||
lifetime: klass.LIFE_TIME || Lifetime.SINGLETON,
|
||||
}),
|
||||
})
|
||||
|
||||
container.registerAdd(FulfillmentIdentifiersRegistrationName, asValue(key))
|
||||
}
|
||||
),
|
||||
})
|
||||
|
||||
container.registerAdd(FulfillmentIdentifiersRegistrationName, asValue(key))
|
||||
}
|
||||
|
||||
export default async ({
|
||||
|
||||
Reference in new issue
Block a user