chore: move ModuleRegistrationName to utils (#7911)

This commit is contained in:
Carlos R. L. Rodrigues
2024-07-03 06:30:56 -03:00
committed by GitHub
parent 46f15b4909
commit a7844efd09
339 changed files with 7203 additions and 7620 deletions
@@ -49,61 +49,58 @@ For example:
<CodeTabs groupId="resource-type">
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService =
request.scope.resolve(ModuleRegistrationName.STORE)
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService = request.scope.resolve(
ModuleRegistrationName.STORE
)
res.json({
stores: await storeModuleService.listStores(),
})
}
```
res.json({
stores: await storeModuleService.listStores(),
})
}
```
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
export default async function subscriberHandler({
container,
}: SubscriberArgs) {
const storeModuleService: IStoreModuleService =
container.resolve(ModuleRegistrationName.STORE)
export default async function subscriberHandler({ container }: SubscriberArgs) {
const storeModuleService: IStoreModuleService = container.resolve(
ModuleRegistrationName.STORE
)
const stores = await storeModuleService.listStores()
}
```
const stores = await storeModuleService.listStores()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
const step1 = createStep(
"step-1",
async (_, { container }) => {
const storeModuleService: IStoreModuleService =
container.resolve(
ModuleRegistrationName.STORE
)
const stores = await storeModuleService.listStores()
})
```
const step1 = createStep("step-1", async (_, { container }) => {
const storeModuleService: IStoreModuleService = container.resolve(
ModuleRegistrationName.STORE
)
const stores = await storeModuleService.listStores()
})
```
</CodeTab>
</CodeTabs>