docs: replace ModuleRegistrationName with Modules (#9142)

This commit is contained in:
Shahed Nasser
2024-09-16 15:30:03 +03:00
committed by GitHub
parent 8829f89402
commit 8584031041
55 changed files with 389 additions and 391 deletions
@@ -16,11 +16,11 @@ In this guide, youll find common examples of how you can use the Customer Mod
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
ModuleRegistrationName.CUSTOMER
Modules.CUSTOMER
)
const customer = await customerModuleService.createCustomers({
@@ -71,11 +71,11 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
ModuleRegistrationName.CUSTOMER
Modules.CUSTOMER
)
const customerGroup = await customerModuleService.createCustomerGroups({
@@ -122,11 +122,11 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
ModuleRegistrationName.CUSTOMER
Modules.CUSTOMER
)
await customerModuleService.addCustomerToGroup({
@@ -171,11 +171,11 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
ModuleRegistrationName.CUSTOMER
Modules.CUSTOMER
)
await customerModuleService.removeCustomerFromGroup({
@@ -10,7 +10,7 @@ The Customer Module is the `@medusajs/customer` NPM package that provides custom
## How to Use Customer Module's Service
You can use the Customer Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.CUSTOMER` imported from `@medusajs/utils`.
You can use the Customer Module's main service by resolving from the Medusa container the resource `Modules.CUSTOMER` imported from `@medusajs/utils`.
For example:
@@ -20,11 +20,11 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
export async function GET(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
ModuleRegistrationName.CUSTOMER
Modules.CUSTOMER
)
res.json({
@@ -39,11 +39,11 @@ export async function GET(request: MedusaRequest, res: MedusaResponse) {
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const customerModuleService: ICustomerModuleService = container.resolve(
ModuleRegistrationName.CUSTOMER
Modules.CUSTOMER
)
const customers = await customerModuleService.listCustomers()
@@ -56,11 +56,11 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { ICustomerModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const customerModuleService: ICustomerModuleService = container.resolve(
ModuleRegistrationName.CUSTOMER
Modules.CUSTOMER
)
const customers = await customerModuleService.listCustomers()