docs: add routing page (#9550)

- Add a new homepage to `book` project for the routing page
- Move all main doc pages to be under `/v2/learn` (and added redirects + fixed links across docs)
- Other: add admin components to resources dropdown + fixes to search on mobile.

Closes DX-955

Preview: https://docs-v2-git-docs-router-page-medusajs.vercel.app/v2
This commit is contained in:
Shahed Nasser
2024-10-18 08:24:34 +00:00
committed by GitHub
parent 7a47f5211d
commit 0a37675f0e
223 changed files with 2549 additions and 696 deletions
@@ -0,0 +1,55 @@
export const metadata = {
title: `${pageNumber} Commerce Modules`,
}
# {metadata.title}
In this chapter, you'll learn about Medusa's commerce modules.
## What is a Commerce Module?
Medusa provides all its commerce features as separate commerce modules, such as the Product or Order modules. Medusa uses these modules in its API routes to expose their commerce features.
Medusa's commerce modules and your custom modules are interchangeable in the Medusa application, making Medusas architecture more flexible.
### List of Medusa's Commerce Modules
Refer to [this reference](!resources!/commerce-modules) for a full list of commerce modules in Medusa.
---
## Resolve Commerce Module Services
Similarly to your custom module, a commerce module's main service is registered in the Medusa container. So, you can resolve it in your resources, such as API routes, to use its functionality.
For example, you saw this code snippet in the [Medusa container chapter](../medusa-container/page.mdx):
```ts highlights={[["10"]]}
import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export const GET = async (
req: MedusaRequest,
res: MedusaResponse
) => {
const productModuleService: IProductModuleService = req.scope.resolve(
Modules.PRODUCT
)
const [, count] = await productModuleService
.listAndCountProducts()
res.json({
count,
})
}
```
When you resolve the `Modules.PRODUCT` (or `productModuleService`) registration name, you're actually resolving the main service of the Product Module.
<Note title="Tip">
To resolve the main service of any commerce module, use the registration name defined in the `Modules` enum imported from `@medusajs/framework/utils`.
</Note>