feat(medusa): Modules initializer (#3352)

This commit is contained in:
Carlos R. L. Rodrigues
2023-03-17 12:18:52 -03:00
committed by GitHub
parent 8a7421db5b
commit aa690beed7
51 changed files with 1290 additions and 715 deletions
@@ -0,0 +1,24 @@
import { IEventBusService, IInventoryService } from "@medusajs/medusa"
import {
ExternalModuleDeclaration,
InternalModuleDeclaration,
MedusaModule,
} from "@medusajs/modules-sdk"
import { InventoryServiceInitializeOptions } from "../types"
export const initialize = async (
options?: InventoryServiceInitializeOptions | ExternalModuleDeclaration,
injectedDependencies?: {
eventBusService: IEventBusService
}
): Promise<IInventoryService> => {
const serviceKey = "inventoryService"
const loaded = await MedusaModule.bootstrap(
serviceKey,
"@medusajs/inventory",
options as InternalModuleDeclaration | ExternalModuleDeclaration,
injectedDependencies
)
return loaded[serviceKey] as IInventoryService
}