**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { createDefaultsWorkflow } from "@medusajs/core-flows"
|
|
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
|
import {
|
|
IRegionModuleService,
|
|
IStoreModuleService,
|
|
MedusaContainer,
|
|
} from "@medusajs/types"
|
|
|
|
export const seedStorefrontDefaults = async (
|
|
container: MedusaContainer,
|
|
defaultCurrency: string = "usd"
|
|
) => {
|
|
const regionModule: IRegionModuleService = container.resolve(
|
|
ModuleRegistrationName.REGION
|
|
)
|
|
const storeModule: IStoreModuleService = container.resolve(
|
|
ModuleRegistrationName.STORE
|
|
)
|
|
|
|
// Creates the stores & default sales channel
|
|
await createDefaultsWorkflow(container).run()
|
|
|
|
const region = await regionModule.createRegions({
|
|
name: "Default Region",
|
|
currency_code: defaultCurrency,
|
|
})
|
|
|
|
let [store] = await storeModule.listStores({})
|
|
|
|
store = await storeModule.updateStores(store.id, {
|
|
default_region_id: region.id,
|
|
supported_currency_codes: [region.currency_code],
|
|
default_currency_code: region.currency_code,
|
|
})
|
|
|
|
return {
|
|
region,
|
|
store,
|
|
}
|
|
}
|