This repo provides the skeleton to get you started with using Medusa. Follow the steps below to get ready.
This starter has minimal prerequisites and most of these will usually already be installed on your computer.
-
Reset DB and Run current migrations
yarn db:reset medusa migrations run
-
Create an Entity & Module
yarn medex g --entity <ENTITY NAME> yarn medex g --module <ENTITY NAME>
-
Build - Transpile all files inside
dist
directoryyarn build
-
Generate Migration
yarn typeorm migration:generate -n <MIGRATION NAME>
-
Add Migration to Module
Within `src/modules/migrations` add the new migration to the MigrationModule
-
Run Medex Migration
yarn medex migrate --run
- Install dependencies
yarn
- Run store
medusa migrations run yarn medex migrate --run yarn start
Your local Medusa server is now running on port 9000.
You must addd ADMIN_CORS
in order to successfully authenticate the Admin portal. It's currently defaulted to http://localhost:8080
.
To create a new admin user from the command line, run the following command:
medusa user -e <EMAIL> -p <PASSWORD>
Alternatively, if you've seeded your server with our dummy data, you can use the following credentials:
[email protected] // supersecret
To seed your medusa store run the following command:
yarn seed
This command seeds your database with some sample datal to get you started, including a store, an administrator account, a region and a product with variants. What the data looks like precisely you can see in the ./data/seed.json
file.
-
Install the Medusa CLI
npm install -g @medusajs/medusa-cli
-
Create a new Medusa project
medusa new my-medusa-store
-
Update project config in
medusa-config.js
:module.exports = { projectConfig: { redis_url: REDIS_URL, database_url: DATABASE_URL, //postgres connectionstring database_type: "postgres", store_cors: STORE_CORS, admin_cors: ADMIN_CORS, }, plugins, };
-
Run your project
When running your project the first time
docker compose
should be run with thebuild
flag to build your contianer locally:docker compose up --build
When running your project subsequent times you can run docker compose with no flags to spin up your local environment in seconds:
docker compose up
Your local Medusa server is now running on port 9000.
To add seed data to your medusa store runnign with Docker, run this command in a seperate terminal:
docker exec medusa-server medusa seed -f ./data/seed.json
This will execute the previously described seed script in the running medusa-server
Docker container.
curl -X GET localhost:9000/store/products | python -m json.tool
After the seed script has run you will have the following things in you database:
- a User with the email: [email protected] and password: supersecret
- a Region called Default Region with the countries GB, DE, DK, SE, FR, ES, IT
- a Shipping Option called Standard Shipping which costs 10 EUR
- a Product called Cool Test Product with 4 Product Variants that all cost 19.50 EUR
Visit docs.medusa-commerce.com for further guides.
Website | Notion Home | Twitter | Docs