1 import { MedusaModule } from "@medusajs/framework/modules-sdk"
2 import {
3 ExternalModuleDeclaration,
4 IEventBusService,
5 InternalModuleDeclaration,
6 } from "@medusajs/framework/types"
7 import { Modules } from "@medusajs/framework/utils"
8 import { EventBusRedisModuleOptions } from "../types"
9
10 export const initialize = async (
11 options?: EventBusRedisModuleOptions | ExternalModuleDeclaration
12 ): Promise<IEventBusService> => {
13 const serviceKey = Modules.EVENT_BUS
14 const loaded = await MedusaModule.bootstrap<IEventBusService>({
15 moduleKey: serviceKey,
16 defaultPath: "@medusajs/event-bus-redis",
17 declaration: options as
18 | InternalModuleDeclaration
19 | ExternalModuleDeclaration,
20 })
21
22 return loaded[serviceKey]
23 }