Skip to content

Commit

Permalink
Merge branch 'develop' into docs/router-page
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Oct 16, 2024
2 parents 0d5faf9 + 3610d58 commit 3e0a172
Show file tree
Hide file tree
Showing 43 changed files with 595 additions and 583 deletions.
2 changes: 1 addition & 1 deletion www/apps/book/app/learn/deployment/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You must deploy the Medusa server before the admin or storefront, as both of the

![Diagram showcasing how the Medusa server and its associated services would be deployed](https://res.cloudinary.com/dza7lstvk/image/upload/v1708600972/Medusa%20Book/backend_deployment_pgexo3.jpg)

The Medusa server must be deployed to a hosting provider supporting Node.js server deployments, such as Railway, DigitalOcean, AWS, Heruko, etc…
The Medusa server must be deployed to a hosting provider supporting Node.js server deployments, such as Railway, DigitalOcean, AWS, Heroku, etc…

<Note title="Tip">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the API Key Module in your application.

<Note>

You should only use the API Key Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create an API Key

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the Auth Module in your application.

<Note>

You should only use the Auth Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Authenticate User

<Note>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the Cart Module in your application.

<Note>

You should only use the Cart Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create a Cart

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the Currency Module in your application.

<Note>

You should only use the Currency Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## List Currencies

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the Customer Module in your application.

<Note>

You should only use the Customer Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create a Customer

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this document, you’ll find common examples of how you can use the Inventory Module in your application.

<Note>

You should only use the Inventory Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create an Inventory Item

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the Payment Module in your application.

<Note>

You should only use the Payment Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create a Payment Collection

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this document, you’ll find common examples of how you can use the Pricing Module in your application.

<Note>

You should only use the Pricing Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create a Price Set

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the Product Module in your application.

<Note>

You should only use the Product Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create Product

<CodeTabs groupId="app-type">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this document, you’ll find common examples of how you can use the Promotion Module in your application.

<Note>

You should only use the Promotion Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create a Promotion

<CodeTabs groupId="app-type">
Expand Down
51 changes: 26 additions & 25 deletions www/apps/resources/app/commerce-modules/region/examples/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@ export const metadata = {

In this guide, you’ll find common examples of how you can use the Region Module in your application.

<Note>

You should only use the Region Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).

</Note>

## Create a Region

<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">

```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"

export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)

Expand Down Expand Up @@ -69,16 +74,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">

```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"

export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)

Expand Down Expand Up @@ -115,16 +119,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">

```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"

export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)

Expand Down Expand Up @@ -161,16 +164,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">

```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"

export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)

Expand Down Expand Up @@ -211,16 +213,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">

```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"

export async function DELETE(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const metadata = {
title: `Links between Region Module and Other Modules`,
}

# {metadata.title}

This document showcases the module links defined between the Region Module and other commerce modules.

## Payment Module

You can specify for each region which payment providers are available for use.

Medusa defines a module link between the `PaymentProvider` and the `Region` data models.

![A diagram showcasing an example of how resources from the Payment and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711569520/Medusa%20Resources/payment-region_jyo2dz.jpg)
53 changes: 25 additions & 28 deletions www/apps/resources/app/commerce-modules/region/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const metadata = {

# {metadata.title}

The Region Module is the `@medusajs/medusa/region` NPM package that provides region-related features in your Medusa and Node.js applications.
The Region Module provides region-related features in your Medusa and Node.js applications.

## How to Use Region Module's Service

Expand All @@ -15,18 +15,33 @@ You can use the Region Module's main service by resolving from the Medusa contai
For example:

<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">

```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"

const step1 = createStep("step-1", async (_, { container }) => {
const regionModuleService = container.resolve(
Modules.REGION
)

const regions = await regionModuleService.listRegions()
})
```

</CodeTab>
<CodeTab label="API Route" value="api-route">

```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"

export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)

Expand All @@ -39,35 +54,17 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">

```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"

export default async function subscriberHandler({ container }: SubscriberArgs) {
const regionModuleService: IRegionModuleService = container.resolve(
const regionModuleService = container.resolve(
Modules.REGION
)

const regions = await regionModuleService.listRegions()
}
```

</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">

```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"

const step1 = createStep("step-1", async (_, { container }) => {
const regionModuleService: IRegionModuleService = container.resolve(
Modules.REGION
)

const regions = await regionModuleService.listRegions()
})
```

</CodeTab>
Expand Down

This file was deleted.

Loading

0 comments on commit 3e0a172

Please sign in to comment.