24 lines
694 B
TypeScript
24 lines
694 B
TypeScript
import { MedusaModule } from "@medusajs/modules-sdk"
|
|
import {
|
|
ExternalModuleDeclaration,
|
|
ICacheService,
|
|
InternalModuleDeclaration,
|
|
} from "@medusajs/types"
|
|
import { Modules } from "@medusajs/utils"
|
|
import { InMemoryCacheModuleOptions } from "../types"
|
|
|
|
export const initialize = async (
|
|
options?: InMemoryCacheModuleOptions | ExternalModuleDeclaration
|
|
): Promise<ICacheService> => {
|
|
const serviceKey = Modules.CACHE
|
|
const loaded = await MedusaModule.bootstrap<ICacheService>({
|
|
moduleKey: serviceKey,
|
|
defaultPath: "@medusajs/cache-inmemory",
|
|
declaration: options as
|
|
| InternalModuleDeclaration
|
|
| ExternalModuleDeclaration,
|
|
})
|
|
|
|
return loaded[serviceKey]
|
|
}
|