Files
medusa-store/www/apps/book/app/learn/first-customizations/page.mdx
Shahed Nasser 37eeaa84a2 docs: small improvement to first customization guide (#9843)
Added a bit more context and what you'll build in the first customization guide and why it's powerful.

Closes DX-1044
2024-11-06 09:09:35 +00:00

68 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const metadata = {
title: `${pageNumber} Your First Customizations`,
}
# {metadata.title}
In this chapter, youll build your first customizations with Medusa.
You'll create a `GET` API route at the path `/hello-world`. An API route exposes your application's commerce features to frontend clients, such as the admin dashboard or a storefront.
Medusa has [Store](!api!/store) and [Admin](!api!/admin) API routes, and you can create custom API routes for your custom features.
## 1. Create API Route
API Routes expose business logic through REST APIs. You can create custom API routes to expose custom business logic.
To create an API route, create the file `src/api/hello-world/route.ts` with the following content:
```ts title="src/api/hello-world/route.ts"
import type {
MedusaRequest,
MedusaResponse,
} from "@medusajs/framework/http"
export const GET = (
req: MedusaRequest,
res: MedusaResponse
) => {
res.json({
message: "Hello, world!",
})
}
```
---
## 2. Test Customizations
To test out your customizations:
1. Start the Medusa application:
```bash npm2yarn
npm run dev
```
2. Send a `GET` request to `/hello-world`:
```bash
curl http://localhost:9000/hello-world
```
In the response, youll receive the following object:
```json
{
"message": "Hello, world!"
}
```
---
## Next Steps
Congratulations, youve made your first customization with Medusa!
You can now start your in-depth learning journey to become an expert.