docs: update modules chapter in basics (#9452)

* docs: update modules chapter in basics

* address PR feedback
This commit is contained in:
Shahed Nasser
2024-10-04 14:15:41 +03:00
committed by GitHub
parent d98f22c7d6
commit ed174826a4
24 changed files with 339 additions and 319 deletions

View File

@@ -1,105 +0,0 @@
export const metadata = {
title: `${pageNumber} Data Models`,
}
# {metadata.title}
In this chapter, youll learn what data models are and how to create a data model.
## What is a Data Model?
A data model is a class that represents a table in the database.
A data model is created in a module, and its record are managed in the database using the module's service.
---
## How to Create a Data Model?
A data model is created in a TypeScript or JavaScript file under a module's `models` directory. It's defined using the `model` utility imported from `@medusajs/framework/utils`.
For example, create the file `src/modules/hello/models/my-custom.ts` with the following content:
```ts title="src/modules/hello/models/my-custom.ts"
import { model } from "@medusajs/framework/utils"
const MyCustom = model.define("my_custom", {
id: model.id().primaryKey(),
name: model.text(),
})
export default MyCustom
```
You define a data model using the `model`'s `define` method. It accepts two parameters:
1. The first one is the name of the data model's table in the database. It should be in snake-case form.
2. The second is an object, which is the data model's schema. The schema's properties are defined using the `model`'s methods.
The example above defines the data model `MyCustom` with the properties `id` and `name`.
### Generate a Migration
A migration is a TypeScript or JavaScript file that defines changes to be made in the database, such as creating a new table or updating it.
To generate a migration for the data models in your module, run the following command:
```bash
npx medusa db:generate helloModuleService
```
The `db:generate` command of the Medusa CLI accepts one or more module names to generate the migration for.
The module name (for example, `helloModuleService`) is the key used when registering the module in the `modules` configuration in `medusa-config.js`.
The above command creates a migration file at the directory `src/modules/hello/migrations` similar to the following:
```ts
import { Migration } from "@mikro-orm/migrations"
export class Migration20240702105919 extends Migration {
async up(): Promise<void> {
this.addSql("create table if not exists \"my_custom\" (\"id\" text not null, \"name\" text not null, \"created_at\" timestamptz not null default now(), \"updated_at\" timestamptz not null default now(), \"deleted_at\" timestamptz null, constraint \"my_custom_pkey\" primary key (\"id\"));")
}
async down(): Promise<void> {
this.addSql("drop table if exists \"my_custom\" cascade;")
}
}
```
In the migration class, the `up` method creates the table `my_custom` and defines its columns. The `down` method drops the table.
<Note>
Data models automatically have the date properties `created_at`, `updated_at`, and `deleted_at`.
</Note>
### Run Migration
To reflect the changes in the generated migration file, run the `migration` command:
```bash
npx medusa db:migrate
```
If ran successfully, the `my_custom` table will be created in the database.
---
## When to Use Data Models
<Note title="Use data models when" type="success">
You want to store data related to your customization in the database.
</Note>
<Note title="Don't use data models if" type="error">
You want to store simple key-value pairs related to an existing data model. Instead, use the `metadata` field that most existing models have, which is an object of custom key-value pairs.
</Note>

View File

@@ -1,153 +0,0 @@
export const metadata = {
title: `${pageNumber} Modules and Services`,
}
# {metadata.title}
In this chapter, youll learn about modules, their main service, and how to create them.
## What is a Module?
A module is a package of reusable commerce or architectural functionalities. It's integrated as a building block in your Medusa application, without implications on the existing setup.
A module has a service, which is a class that can connect to the database or third-party systems to provide custom features. The service's methods are then used by other resources, such as API routes.
---
## How to Create a Module?
Modules are created in a sub-directory of `src/modules`.
For example, create the directory `src/modules/hello`.
### 1. Create Main Service
A module must define a service. A service is a TypeScript or JavaScript class used to perform actions on the database or connect to third-party services.
A service must be defined at the root of your module directory under `service.ts` filename.
For example, create the file `src/modules/hello/service.ts` with the following content:
```ts title="src/modules/hello/service.ts"
export default class HelloModuleService {
async getMessage() {
return "Hello, world!"
}
}
```
### 2. Export Module Definition
A module must have an `index.ts` file in its root directory that exports its definition. The definition specifies the main service of the module.
For example, create the file `src/modules/hello/index.ts` with the following content:
```ts title="src/modules/hello/index.ts" highlights={[["7", "", "The main service of the module."]]}
import HelloModuleService from "./service"
import { Module } from "@medusajs/framework/utils"
export const HELLO_MODULE = "helloModuleService"
export default Module(HELLO_MODULE, {
service: HelloModuleService,
})
```
You use the `Module` function imported from `@medusajs/framework/utils` to create the module definition. It requires two parameters:
1. The module's name.
2. An object with a required property `service` indicating the module's main service.
### 3. Add Module to Configurations
The last step is to add the module in Medusas configurations.
In `medusa-config.js`, add a `modules` property and pass to it your custom module:
```js title="medusa-config.js" highlights={[["7", "helloModuleService", "The key of the main service to be registered in the Medusa container."]]}
module.exports = defineConfig({
projectConfig: {
// ...
},
modules: {
helloModuleService: {
resolve: "./modules/hello",
},
},
})
```
Its key (`helloModuleService`) is the name of the modules main service. It will be registered in the Medusa container with that name.
<Note title="Tip">
It should also be the same name passed as the first parameter to the `Module` function in the module's definition.
</Note>
Its value is an object having the `resolve` property, whose value is either a path to module's directory relative to `src`(it shouldn't include `src` in the path), or an `npm` packages name.
---
## Test the Module
Since the module's main service is registered in the Medusa container, you can resolve it in other resources to use its methods.
<Note title="Tip">
Resolving a module's service is essential to use its methods that perform actions on the database or connect to a third-party service.
</Note>
For example, create the API route `src/api/custom/route.ts` with the following content:
```ts title="src/api/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import HelloModuleService from "../../modules/hello/service"
import { HELLO_MODULE } from "../../modules/hello"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const helloModuleService: HelloModuleService = req.scope.resolve(
HELLO_MODULE
)
res.json({
message: await helloModuleService.getMessage(),
})
}
```
Then, start the Medusa application:
```bash npm2yarn
npm run dev
```
Finally, send a `GET` request to `/custom`:
```bash
curl http://localhost:9000/custom
```
Youll receive the following response:
```json
{
"message": "Hello, world!"
}
```
---
## When to Use Modules
<Note title="Use modules when" type="success">
- You're adding new tables to the database, as explained in later chapters.
- You're integrating a third-party system for commerce or architectural features.
- You want to re-use your custom commerce functionalities across Medusa applications or use them in other environments, such as Edge functions and Next.js apps.
</Note>

View File

@@ -10,13 +10,13 @@ In this document, you'll learn about the expected files and directories in your
## index.ts
The `index.ts` file in the root of your module's directory is the only required file. It must export the module's definition as explained in a [previous chapter](../modules-and-services/page.mdx).
The `index.ts` file in the root of your module's directory is the only required file. It must export the module's definition as explained in a [previous chapter](../modules/page.mdx).
---
## service.ts
A module must have a main service. It's created in the `service.ts` file at the root of your module directory as explained in a [previous chapter](../modules-and-services/page.mdx).
A module must have a main service. It's created in the `service.ts` file at the root of your module directory as explained in a [previous chapter](../modules/page.mdx).
---

View File

@@ -0,0 +1,274 @@
export const metadata = {
title: `${pageNumber} Modules`,
}
# {metadata.title}
In this chapter, youll learn about modules and how to create them.
## What is a Module?
A module is a package of reusable commerce or architectural functionalities.
In Medusa, modules handle business logic in a class called a service, and define and manage data models that represent tables in the database.
Out of the box, Medusa comes with multiple pre-built modules for core commerce needs. For example, the Cart Module holds the data models and business logic for cart operations.
As you learn more about Medusa, you will see that Modules are central to customizations and integrations.
---
## How to Create a Module?
In this section, you'll build a module that has a `MyCustom` data model and a service to manage that data model. You'll then use the module's service in an API route to create a record of `MyCustom`.
Modules are created in a sub-directory of `src/modules`.
For example, create the directory `src/modules/hello`.
### 1. Create Data Model
A data model represents a table in the database. It's created in a TypeScript or JavaScript file under the module's `models` directory.
For example, create the file `src/modules/hello/models/my-custom.ts` with the following content:
```ts title="src/modules/hello/models/my-custom.ts"
import { model } from "@medusajs/framework/utils"
const MyCustom = model.define("my_custom", {
id: model.id().primaryKey(),
name: model.text(),
})
export default MyCustom
```
You define the data model using the `define` method of the `model` utility imported from `@medusajs/framework/utils`. It accepts two parameters:
1. The first one is the name of the data model's table in the database. It should be snake-case.
2. The second is an object, which is the data model's schema. The schema's properties are defined using the `model`'s methods.
The example above defines the data model `MyCustom` with the properties `id` and `name`.
<Note>
Data models automatically have the date properties `created_at`, `updated_at`, and `deleted_at`.
</Note>
### 2. Create Service
A module must define a service that implements its functionalities, such as manage the records of your custom data models in the database.
A service is a TypeScript or JavaScript class defined in the `service.ts` file at the root of your module's directory.
For example, create the file `src/modules/hello/service.ts` with the following content:
export const highlights = [
["4", "MedusaService", "The service factory function."],
["5", "MyCustom", "The data models to generate data-management methods for."]
]
```ts title="src/modules/hello/service.ts" highlights={highlights}
import { MedusaService } from "@medusajs/framework/utils"
import MyCustom from "./models/my-custom"
class HelloModuleService extends MedusaService({
MyCustom,
}){
}
export default HelloModuleService
```
In the snippet above, your module's service extends a class generated by the `MedusaService` utility function, which is the service factory.
The `MedusaService` function accepts as a parameter an object of data models, and returns a class with generated methods for data-management Create, Read, Update, and Delete (CRUD) operations on those data models.
For example, `HelloModuleService` now has a `createMyCustoms` method to create `MyCustom` records, and `retrieveMyCustom` to retrive a `MyCustom` record.
<Note title="Tip">
If a module doesn't have data models, it doesn't need to extend `MedusaService`.
</Note>
<Note>
You'll learn more about the methods generated by the service factory in later chapters.
</Note>
### 3. Export Module Definition
A module must have an `index.ts` file in its root directory. The file exports the module's definition.
For example, create the file `src/modules/hello/index.ts` with the following content:
```ts title="src/modules/hello/index.ts" highlights={[["7", "", "The main service of the module."]]}
import HelloModuleService from "./service"
import { Module } from "@medusajs/framework/utils"
export const HELLO_MODULE = "helloModuleService"
export default Module(HELLO_MODULE, {
service: HelloModuleService,
})
```
You use the `Module` function imported from `@medusajs/framework/utils` to create the module's definition. It accepts two parameters:
1. The module's name.
2. An object with a required property `service` indicating the module's main service.
### 4. Add Module to Configurations
The last step is to add the module in Medusas configurations.
In `medusa-config.js`, add a `modules` property and pass to it your custom module:
```js title="medusa-config.js" highlights={[["6", "helloModuleService", "The key of the main service to be registered in the Medusa container."]]}
module.exports = defineConfig({
projectConfig: {
// ...
},
modules: {
helloModuleService: {
resolve: "./modules/hello",
},
},
})
```
The key `helloModuleService` is the name of the modules main service. It will be registered in the Medusa container with that name.
<Note>
The key must be the same value passed as the first parameter to the `Module` function in the module's definition.
</Note>
Its value is an object having the `resolve` property, whose value is either a path to module's directory relative to `src` (it shouldn't include `src` in the path), or an `npm` packages name.
### 5. Generate Migrations
A migration is a TypeScript or JavaScript file that defines database changes made by your module, such as create the `my_custom` table for the `MyCustom` data model.
To generate a migration for the data models in your module, run the following command:
```bash
npx medusa db:generate helloModuleService
```
The `db:generate` command of the Medusa CLI accepts one or more module names to generate the migration for.
<Note>
The module name `helloModuleService` is the key used when registering the module in Medusa's `modules` configuration.
</Note>
The above command creates a migration file at the directory `src/modules/hello/migrations` similar to the following:
```ts
import { Migration } from "@mikro-orm/migrations"
export class Migration20240702105919 extends Migration {
async up(): Promise<void> {
this.addSql("create table if not exists \"my_custom\" (\"id\" text not null, \"name\" text not null, \"created_at\" timestamptz not null default now(), \"updated_at\" timestamptz not null default now(), \"deleted_at\" timestamptz null, constraint \"my_custom_pkey\" primary key (\"id\"));")
}
async down(): Promise<void> {
this.addSql("drop table if exists \"my_custom\" cascade;")
}
}
```
In the migration class, the `up` method creates the table `my_custom` and defines its columns using PostgreSQL syntax. The `down` method drops the table.
### 6. Run Migrations
To reflect the changes in the generated migration file, run the `db:migrate` command:
```bash
npx medusa db:migrate
```
This creates the `my_custom` table in the database.
---
## Test the Module
Since the module's main service is registered in the Medusa container, you can resolve it in other resources to use its methods.
For example, create the API route `src/api/custom/route.ts` with the following content:
```ts title="src/api/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import HelloModuleService from "../../modules/hello/service"
import { HELLO_MODULE } from "../../modules/hello"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const helloModuleService: HelloModuleService = req.scope.resolve(
HELLO_MODULE
)
const my_custom = await helloModuleService.createMyCustoms({
name: "test"
})
res.json({
my_custom
})
}
```
You resolve the Hello Module's main service and use its generated method `createMyCustoms` to create a new record in the database, then return that record.
Then, start the Medusa application:
```bash npm2yarn
npm run dev
```
Finally, send a `GET` request to `/custom`:
```bash
curl http://localhost:9000/custom
```
Youll receive the following response:
```json
{
"my_custom": {
"id": "123...",
"name": "test",
"created_at": "...",
"updated_at": "..."
}
}
```
---
## Why Use Modules
In digital commerce, you often need to introduce custom behavior specific to your products, industry, tech stack, or your general ways of working. In other commerce platforms, introducing custom business logic and data models requires setting up separate applications to manage these customizations.
Medusa removes this overhead by allowing you to easily write custom Modules that integrate into the Medusa application without implications on the existing setup.
<Note title="Use modules when" type="success">
- You're adding a new table to the database.
- You're extending an existing table in the database to add custom fields, which is explained in later chapters.
- You're integrating a third-party system for commerce or architectural features, as explained in later chapters.
- You want to re-use your custom commerce functionalities across Medusa applications or use them in other environments, such as Edge functions and Next.js apps.
</Note>

View File

@@ -1,5 +1,5 @@
export const metadata = {
title: `${pageNumber} Project Directories and Files`,
title: `${pageNumber} Project File Conventions`,
}
# {metadata.title}

View File

@@ -89,7 +89,7 @@ This exposes the module to your application and allows you to resolve the `Brand
<Note>
Learn more about modules and services [in this guide](../../../basics/modules-and-services/page.mdx).
Learn more about modules and services [in this guide](../../../basics/modules/page.mdx).
</Note>

View File

@@ -3,7 +3,6 @@ export const generatedEditDates = {
"app/basics/workflows/page.mdx": "2024-09-30T08:43:53.132Z",
"app/deployment/page.mdx": "2024-08-05T07:24:05+00:00",
"app/page.mdx": "2024-09-03T07:09:09.034Z",
"app/basics/modules-and-services/page.mdx": "2024-09-30T08:43:53.132Z",
"app/basics/commerce-modules/page.mdx": "2024-09-30T08:43:53.131Z",
"app/advanced-development/workflows/retry-failed-steps/page.mdx": "2024-09-30T08:43:53.130Z",
"app/advanced-development/workflows/workflow-hooks/page.mdx": "2024-09-30T08:43:53.131Z",
@@ -20,13 +19,12 @@ export const generatedEditDates = {
"app/first-customizations/page.mdx": "2024-09-11T10:48:42.374Z",
"app/debugging-and-testing/page.mdx": "2024-05-03T17:36:38+03:00",
"app/basics/medusa-container/page.mdx": "2024-09-30T08:43:53.132Z",
"app/basics/project-directories-files/page.mdx": "2024-07-04T17:26:03+03:00",
"app/basics/project-directories-files/page.mdx": "2024-10-03T12:46:52.762Z",
"app/basics/api-routes/page.mdx": "2024-09-11T10:48:31.777Z",
"app/basics/modules-directory-structure/page.mdx": "2024-05-07T18:00:28+02:00",
"app/basics/modules-directory-structure/page.mdx": "2024-10-03T13:03:35.957Z",
"app/advanced-development/workflows/access-workflow-errors/page.mdx": "2024-09-18T12:54:04.695Z",
"app/basics/events-and-subscribers/page.mdx": "2024-09-30T08:43:53.131Z",
"app/advanced-development/modules/container/page.mdx": "2024-09-30T08:43:53.125Z",
"app/basics/data-models/page.mdx": "2024-09-30T08:43:53.131Z",
"app/advanced-development/workflows/execute-another-workflow/page.mdx": "2024-09-30T08:43:53.129Z",
"app/basics/loaders/page.mdx": "2024-09-03T08:00:45.993Z",
"app/advanced-development/admin/widgets/page.mdx": "2024-09-30T08:43:53.120Z",
@@ -92,7 +90,7 @@ export const generatedEditDates = {
"app/advanced-development/workflows/page.mdx": "2024-09-18T08:00:57.364Z",
"app/advanced-development/workflows/variable-manipulation/page.mdx": "2024-09-30T08:43:53.130Z",
"app/customization/custom-features/api-route/page.mdx": "2024-09-12T12:42:34.201Z",
"app/customization/custom-features/module/page.mdx": "2024-09-30T08:43:53.133Z",
"app/customization/custom-features/module/page.mdx": "2024-10-03T13:03:41.359Z",
"app/customization/custom-features/workflow/page.mdx": "2024-09-30T08:43:53.133Z",
"app/customization/extend-models/create-links/page.mdx": "2024-09-30T08:43:53.133Z",
"app/customization/extend-models/extend-create-product/page.mdx": "2024-09-30T08:43:53.134Z",
@@ -113,5 +111,6 @@ export const generatedEditDates = {
"app/more-resources/examples/page.mdx": "2024-09-27T07:17:16.892Z",
"app/architecture/architectural-modules/page.mdx": "2024-09-23T12:51:04.520Z",
"app/architecture/overview/page.mdx": "2024-09-23T12:55:01.339Z",
"app/advanced-development/data-models/infer-type/page.mdx": "2024-09-30T08:43:53.123Z"
"app/advanced-development/data-models/infer-type/page.mdx": "2024-09-30T08:43:53.123Z",
"app/basics/modules/page.mdx": "2024-10-03T13:05:49.551Z"
}

View File

@@ -164,6 +164,16 @@ const nextConfig = {
destination: "/advanced-development/architecture/architectural-modules",
permanent: true,
},
{
source: "/basics/modules-and-services",
destination: "/basics/modules",
permanent: true
},
{
source: "/basics/data-models",
destination: "/basics/modules",
permanent: true
}
]
},
}

View File

@@ -24,7 +24,7 @@ export const sidebar = numberSidebarItems(
{
type: "link",
path: "/basics/project-directories-files",
title: "Project Directories and Files",
title: "Project Conventions",
},
{
type: "link",
@@ -33,13 +33,13 @@ export const sidebar = numberSidebarItems(
},
{
type: "link",
path: "/basics/api-routes",
title: "API Routes",
path: "/basics/modules",
title: "Modules",
},
{
type: "link",
path: "/basics/modules-and-services",
title: "Modules and Services",
path: "/basics/api-routes",
title: "API Routes",
},
{
type: "link",
@@ -51,11 +51,6 @@ export const sidebar = numberSidebarItems(
path: "/basics/modules-directory-structure",
title: "Modules Directory Structure",
},
{
type: "link",
path: "/basics/data-models",
title: "Data Models",
},
{
type: "link",
path: "/basics/loaders",

View File

@@ -173,13 +173,13 @@ You can create a B2B module that adds necessary data models to represent a B2B c
<CardList items={[
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create Module",
text: "Learn how to create a module in Medusa.",
icon: AcademicCapSolid,
},
{
href: "!docs!/basics/data-models",
href: "!docs!/basics/modules#1-create-data-model",
title: "Create Data Models",
text: "Learn how to create data models.",
icon: AcademicCapSolid,
@@ -573,7 +573,7 @@ To implement a more advanced B2B sales flow, add custom data models such as `Com
This provides more granular control of your B2B sales and allows you to build features like privileges, limits, and more.
<Card
href="!docs!/basics/data-models"
href="!docs!/basics/modules#1-create-data-model"
title="Create a Data Model"
text="Learn how to create a custom data model in a module."
icon={AcademicCapSolid}

View File

@@ -36,13 +36,13 @@ The `inventory-item.updated` event is currently not emitted.
<CardList items={[
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create a Module",
text: "Learn how to create a module in Medusa.",
icon: AcademicCapSolid,
},
{
href: "!docs!/basics/data-models",
href: "!docs!/basics/modules#1-create-data-model",
title: "Create a Data Model",
text: "Learn how to create a data model.",
icon: AcademicCapSolid,

View File

@@ -204,8 +204,8 @@ module.exports = defineConfig({
### Further Reads
- [How to Create a Module](!docs!/basics/modules-and-services)
- [How to Create a Data Model](!docs!/basics/data-models)
- [How to Create a Module](!docs!/basics/modules)
- [How to Create a Data Model](!docs!/basics/modules#1-create-data-model)
---

View File

@@ -49,7 +49,7 @@ Your custom features and functionalities are implemented inside modules. The mod
The module will hold your custom data models and the service implementing digital-product-related features.
<Card
href="!docs!/basics/modules-and-services"
href="!docs!/basics/modules"
title="How to Create a Module"
text="Learn how to create a module."
icon={AcademicCapSolid}
@@ -63,7 +63,7 @@ Then, you can link your custom data model to data models from other modules. For
<CardList itemsPerRow={2} items={[
{
href: "!docs!/basics/data-models",
href: "!docs!/basics/modules#1-create-data-model",
title: "How to Create a Data Model",
text: "Learn how to create a data model.",
icon: AcademicCapSolid,

View File

@@ -28,7 +28,7 @@ To integrate an external system, such as an ERP, into your Medusa application, c
Then, resolve the module's main service in other resources, such as API routes or workflows, to perform actions in the external system.
<Card
href="!docs!/basics/modules-and-services"
href="!docs!/basics/modules"
title="Create a Module"
text="Learn how to create a module in Medusa."
icon={AcademicCapSolid}
@@ -101,7 +101,7 @@ export const serviceHighlights = [
<Note title="Tip">
You can store the product's ID in the external system using the `metadata` property of the `Product` data model in the Product Module. Alternatively, you can create a [data model](!docs!/basics/data-models) in your module to store data related to the external system.
You can store the product's ID in the external system using the `metadata` property of the `Product` data model in the Product Module. Alternatively, you can create a [data model](!docs!/basics/modules#1-create-data-model) in your module to store data related to the external system.
</Note>

View File

@@ -170,8 +170,8 @@ module.exports = defineConfig({
### Further Reads
- [How to Create a Module](!docs!/basics/modules-and-services)
- [How to Create a Data Model](!docs!/basics/data-models)
- [How to Create a Module](!docs!/basics/modules)
- [How to Create a Data Model](!docs!/basics/modules#1-create-data-model)
---

View File

@@ -150,8 +150,8 @@ module.exports = defineConfig({
### Further Reads
- [How to Create a Module](!docs!/basics/modules-and-services)
- [How to Create Data Models](!docs!/basics/data-models)
- [How to Create a Module](!docs!/basics/modules)
- [How to Create Data Models](!docs!/basics/modules#1-create-data-model)
---

View File

@@ -35,13 +35,13 @@ You can create a marketplace module that implements data models for vendors, the
<CardList items={[
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create a Module",
text: "Learn how to create a module.",
icon: AcademicCapSolid,
},
{
href: "!docs!/basics/data-models",
href: "!docs!/basics/modules#1-create-data-model",
title: "Create Data Models",
text: "Create data models in the module.",
icon: AcademicCapSolid,

View File

@@ -157,7 +157,7 @@ By integrating a third-party Content Management Systems (CMS), you benefit from
To integrate a third-party system, create a custom module whose main service connects to that third-party service.
<Card
href="!docs!/basics/modules-and-services"
href="!docs!/basics/modules"
title="Create a Module"
text="Learn how to create a module in Medusa."
icon={AcademicCapSolid}

View File

@@ -52,7 +52,7 @@ Another channel that attracts customer sales is social media. You can create a c
icon: AcademicCapSolid,
},
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create a Module",
text: "Learn how to create a module.",
icon: AcademicCapSolid,
@@ -73,7 +73,7 @@ Medusas architecture also makes it easier to integrate any third-party servic
<CardList itemsPerRow={2} items={[
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create a Module",
text: "Learn how to create a module.",
icon: AcademicCapSolid,

View File

@@ -48,13 +48,13 @@ In more complex cases, you can create a custom module that stores and manages th
<CardList items={[
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create a Module",
text: "Learn how to create a module.",
icon: AcademicCapSolid,
},
{
href: "!docs!/basics/data-models",
href: "!docs!/basics/modules#1-create-data-model",
title: "Create a Data Model",
text: "Learn how to create a data model.",
icon: AcademicCapSolid,

View File

@@ -167,7 +167,7 @@ You can also create custom modules to provide features for a better customer exp
icon: AcademicCapSolid,
},
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create a Module",
text: "Learn how to create a module.",
icon: AcademicCapSolid,

View File

@@ -168,8 +168,8 @@ module.exports = defineConfig({
### Further Read
- [How to Create a Module](!docs!/basics/modules-and-services)
- [How to Create a Data Model](!docs!/basics/data-models)
- [How to Create a Module](!docs!/basics/modules)
- [How to Create a Data Model](!docs!/basics/modules#1-create-data-model)
- [Learn more about the service factory](!docs!/advanced-development/modules/service-factory).
---

View File

@@ -33,13 +33,13 @@ You can link the subscription data model to models of other modules, such as the
<CardList items={[
{
href: "!docs!/basics/modules-and-services",
href: "!docs!/basics/modules",
title: "Create a Module",
text: "Learn how to create a module.",
icon: AcademicCapSolid,
},
{
href: "!docs!/basics/data-models",
href: "!docs!/basics/modules#1-create-data-model",
title: "Create a Data Model",
text: "Learn how to create a data model.",
icon: AcademicCapSolid,

View File

@@ -139,21 +139,21 @@ export const generatedEditDates = {
"app/medusa-container-resources/page.mdx": "2024-09-30T08:43:53.173Z",
"app/medusa-workflows-reference/page.mdx": "2024-09-30T08:43:53.174Z",
"app/nextjs-starter/page.mdx": "2024-07-01T10:21:19+03:00",
"app/recipes/b2b/page.mdx": "2024-09-30T08:43:53.175Z",
"app/recipes/commerce-automation/page.mdx": "2024-09-30T08:43:53.175Z",
"app/recipes/digital-products/examples/standard/page.mdx": "2024-09-30T08:43:53.176Z",
"app/recipes/digital-products/page.mdx": "2024-08-02T13:02:06+00:00",
"app/recipes/b2b/page.mdx": "2024-10-03T13:07:44.153Z",
"app/recipes/commerce-automation/page.mdx": "2024-10-03T13:07:44.147Z",
"app/recipes/digital-products/examples/standard/page.mdx": "2024-10-03T13:07:44.153Z",
"app/recipes/digital-products/page.mdx": "2024-10-03T13:07:44.147Z",
"app/recipes/ecommerce/page.mdx": "2024-06-09T15:18:43+02:00",
"app/recipes/integrate-ecommerce-stack/page.mdx": "2024-09-30T08:43:53.177Z",
"app/recipes/marketplace/examples/vendors/page.mdx": "2024-09-30T08:43:53.179Z",
"app/recipes/marketplace/page.mdx": "2024-07-11T15:56:41+00:00",
"app/recipes/multi-region-store/page.mdx": "2024-07-01T10:21:19+03:00",
"app/recipes/omnichannel/page.mdx": "2024-06-09T15:18:43+02:00",
"app/recipes/integrate-ecommerce-stack/page.mdx": "2024-10-03T13:07:44.146Z",
"app/recipes/marketplace/examples/vendors/page.mdx": "2024-10-03T13:07:44.153Z",
"app/recipes/marketplace/page.mdx": "2024-10-03T13:07:44.153Z",
"app/recipes/multi-region-store/page.mdx": "2024-10-03T13:07:13.813Z",
"app/recipes/omnichannel/page.mdx": "2024-10-03T13:07:14.384Z",
"app/recipes/oms/page.mdx": "2024-07-01T10:21:19+03:00",
"app/recipes/personalized-products/page.mdx": "2024-09-11T10:53:03.936Z",
"app/recipes/pos/page.mdx": "2024-09-30T08:43:53.180Z",
"app/recipes/subscriptions/examples/standard/page.mdx": "2024-09-30T08:43:53.180Z",
"app/recipes/subscriptions/page.mdx": "2024-08-02T12:40:26+03:00",
"app/recipes/personalized-products/page.mdx": "2024-10-03T13:07:44.153Z",
"app/recipes/pos/page.mdx": "2024-10-03T13:07:13.964Z",
"app/recipes/subscriptions/examples/standard/page.mdx": "2024-10-03T13:07:44.164Z",
"app/recipes/subscriptions/page.mdx": "2024-10-03T13:07:44.155Z",
"app/recipes/page.mdx": "2024-07-11T15:56:41+00:00",
"app/service-factory-reference/methods/create/page.mdx": "2024-07-31T17:01:33+03:00",
"app/service-factory-reference/methods/delete/page.mdx": "2024-07-31T17:01:33+03:00",
@@ -642,7 +642,7 @@ export const generatedEditDates = {
"app/medusa-cli/commands/start/page.mdx": "2024-08-28T10:44:19.952Z",
"app/medusa-cli/commands/telemtry/page.mdx": "2024-08-28T11:25:08.553Z",
"app/medusa-cli/commands/user/page.mdx": "2024-08-28T10:44:52.489Z",
"app/recipes/marketplace/examples/restaurant-delivery/page.mdx": "2024-09-30T08:43:53.178Z",
"app/recipes/marketplace/examples/restaurant-delivery/page.mdx": "2024-10-03T13:07:44.153Z",
"references/types/HttpTypes/interfaces/types.HttpTypes.AdminCreateCustomerGroup/page.mdx": "2024-08-30T00:11:02.074Z",
"references/types/HttpTypes/interfaces/types.HttpTypes.AdminCreateReservation/page.mdx": "2024-08-30T00:11:02.342Z",
"references/types/HttpTypes/interfaces/types.HttpTypes.AdminCustomerGroup/page.mdx": "2024-10-03T00:11:52.871Z",