2. Your First Customizations

In this chapter, you’ll build your first customizations with Medusa.

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/store/hello-world/route.ts with the following content:

src/api/store/hello-world/route.ts
1import type {2  MedusaRequest,3  MedusaResponse,4} from "@medusajs/medusa"5
6export const GET = (7  req: MedusaRequest,8  res: MedusaResponse9) => {10  res.json({11    message: "Hello, world!",12  })13}

2. Test Customizations#

To test out your customizations:

  1. Start the Medusa application:
  1. Send a GET request to /store/hello-world:
curl http://localhost:9000/store/hello-world

In the response, you’ll receive the following object:

1{2  "message": "Hello, world!"3}

Next Steps#

Congratulations, you’ve made your first customization with Medusa!

You can now start your in-depth learning journey to become an expert.

Was this chapter helpful?