Fixes: FRMW-2728, FRMW-2729 After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path. - applyParamsAsFilters - clearFiltersByKey - applyDefaultFilters - setContext - getQueryConfig - httpCompression - maybeApplyLinkFilter - refetchEntities - unlessPath - validateBody - validateQuery Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import {
|
|
LoaderOptions,
|
|
ModuleProvider,
|
|
ModulesSdkTypes,
|
|
} from "@medusajs/framework/types"
|
|
import { asFunction, asValue, Lifetime } from "awilix"
|
|
import { moduleProviderLoader } from "@medusajs/framework/modules-sdk"
|
|
import {
|
|
AuthIdentifiersRegistrationName,
|
|
AuthProviderRegistrationPrefix,
|
|
} from "@types"
|
|
|
|
const registrationFn = async (klass, container, pluginOptions) => {
|
|
container.register({
|
|
[AuthProviderRegistrationPrefix + pluginOptions.id]: asFunction(
|
|
(cradle) => new klass(cradle, pluginOptions.options ?? {}),
|
|
{
|
|
lifetime: klass.LIFE_TIME || Lifetime.SINGLETON,
|
|
}
|
|
),
|
|
})
|
|
|
|
container.registerAdd(
|
|
AuthIdentifiersRegistrationName,
|
|
asValue(pluginOptions.id)
|
|
)
|
|
}
|
|
|
|
export default async ({
|
|
container,
|
|
options,
|
|
}: LoaderOptions<
|
|
(
|
|
| ModulesSdkTypes.ModuleServiceInitializeOptions
|
|
| ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions
|
|
) & { providers: ModuleProvider[] }
|
|
>): Promise<void> => {
|
|
await moduleProviderLoader({
|
|
container,
|
|
providers: options?.providers || [],
|
|
registerServiceFn: registrationFn,
|
|
})
|
|
}
|