|
| 1 | +<p align="center"> |
| 2 | + <a href="https://www.medusa-commerce.com"> |
| 3 | + <img alt="Medusa" src="https://user-images.githubusercontent.com/7554214/129161578-19b83dc8-fac5-4520-bd48-53cba676edd2.png" width="100" /> |
| 4 | + </a> |
| 5 | +</p> |
| 6 | +<h1 align="center"> |
| 7 | + Medusa Starter Default |
| 8 | +</h1> |
| 9 | +<p align="center"> |
| 10 | +This repo provides the skeleton to get you started with using <a href="https://github.com/medusajs/medusa">Medusa</a>. Follow the steps below to get ready. |
| 11 | +</p> |
| 12 | +<p align="center"> |
| 13 | + <a href="https://github.com/medusajs/medusa/blob/master/LICENSE"> |
| 14 | + <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Medusa is released under the MIT license." /> |
| 15 | + </a> |
| 16 | + <a href="https://github.com/medusajs/medusa/blob/master/CONTRIBUTING.md"> |
| 17 | + <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" alt="PRs welcome!" /> |
| 18 | + </a> |
| 19 | + <a href="https://discord.gg/xpCwq3Kfn8"> |
| 20 | + <img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Discord Chat" /> |
| 21 | + </a> |
| 22 | + <a href="https://twitter.com/intent/follow?screen_name=medusajs"> |
| 23 | + <img src="https://img.shields.io/twitter/follow/medusajs.svg?label=Follow%20@medusajs" alt="Follow @medusajs" /> |
| 24 | + </a> |
| 25 | +</p> |
| 26 | + |
| 27 | +## Prerequisites |
| 28 | + |
| 29 | +This starter has minimal prerequisites and most of these will usually already be installed on your computer. |
| 30 | + |
| 31 | +- [Install Node.js](https://nodejs.org/en/download/) |
| 32 | +- [Install git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) |
| 33 | +- [Install SQLite](https://www.sqlite.org/download.html) |
| 34 | + |
| 35 | +## Setting up your store |
| 36 | + |
| 37 | +- Install the Medusa CLI |
| 38 | + ``` |
| 39 | + npm install -g @medusajs/medusa |
| 40 | + yarn global add @medusajs/medusa |
| 41 | + ``` |
| 42 | +- Create a new Medusa project |
| 43 | + ``` |
| 44 | + medusa new my-medusa-store |
| 45 | + ``` |
| 46 | +- Run your project |
| 47 | + ``` |
| 48 | + cd my-medusa-store |
| 49 | + medusa develop |
| 50 | + ``` |
| 51 | + |
| 52 | +Your local Medusa server is now running on port **9000**. |
| 53 | + |
| 54 | +### Seeding your Medusa store |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +To seed your medusa store run the following command: |
| 59 | + |
| 60 | +``` |
| 61 | +medusa seed -f ./data/seed.json |
| 62 | +``` |
| 63 | + |
| 64 | +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. |
| 65 | + |
| 66 | +## Setting up your store with Docker |
| 67 | + |
| 68 | +- Install the Medusa CLI |
| 69 | + ``` |
| 70 | + npm install -g @medusajs/medusa-cli |
| 71 | + ``` |
| 72 | +- Create a new Medusa project |
| 73 | + ``` |
| 74 | + medusa new my-medusa-store |
| 75 | + ``` |
| 76 | +- Update project config in `medusa-config.js`: |
| 77 | + |
| 78 | + ``` |
| 79 | + module.exports = { |
| 80 | + projectConfig: { |
| 81 | + redis_url: REDIS_URL, |
| 82 | + database_url: DATABASE_URL, //postgres connectionstring |
| 83 | + database_type: "postgres", |
| 84 | + store_cors: STORE_CORS, |
| 85 | + admin_cors: ADMIN_CORS, |
| 86 | + }, |
| 87 | + plugins, |
| 88 | + }; |
| 89 | + ``` |
| 90 | + |
| 91 | +- Run your project |
| 92 | + |
| 93 | + When running your project the first time `docker compose` should be run with the `build` flag to build your contianer locally: |
| 94 | + |
| 95 | + ``` |
| 96 | + docker compose up --build |
| 97 | + ``` |
| 98 | + |
| 99 | + When running your project subsequent times you can run docker compose with no flags to spin up your local environment in seconds: |
| 100 | + |
| 101 | + ``` |
| 102 | + docker compose up |
| 103 | + ``` |
| 104 | + |
| 105 | +Your local Medusa server is now running on port **9000**. |
| 106 | + |
| 107 | +### Seeding your Medusa store with Docker |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +To add seed data to your medusa store runnign with Docker, run this command in a seperate terminal: |
| 112 | + |
| 113 | +``` |
| 114 | +docker exec medusa-server medusa seed -f ./data/seed.json |
| 115 | +``` |
| 116 | + |
| 117 | +This will execute the previously described seed script in the running `medusa-server` Docker container. |
| 118 | + |
| 119 | +## Try it out |
| 120 | + |
| 121 | +``` |
| 122 | +curl -X GET localhost:9000/store/products | python -m json.tool |
| 123 | +``` |
| 124 | + |
| 125 | +After the seed script has run you will have the following things in you database: |
| 126 | + |
| 127 | +- a User with the email: admin@medusa-test.com and password: supersecret |
| 128 | +- a Region called Default Region with the countries GB, DE, DK, SE, FR, ES, IT |
| 129 | +- a Shipping Option called Standard Shipping which costs 10 EUR |
| 130 | +- a Product called Cool Test Product with 4 Product Variants that all cost 19.50 EUR |
| 131 | + |
| 132 | +Visit [docs.medusa-commerce.com](https://docs.medusa-commerce.com) for further guides. |
| 133 | + |
| 134 | +<p> |
| 135 | + <a href="https://www.medusa-commerce.com"> |
| 136 | + Website |
| 137 | + </a> |
| 138 | + | |
| 139 | + <a href="https://medusajs.notion.site/medusajs/Medusa-Home-3485f8605d834a07949b17d1a9f7eafd"> |
| 140 | + Notion Home |
| 141 | + </a> |
| 142 | + | |
| 143 | + <a href="https://twitter.com/intent/follow?screen_name=medusajs"> |
| 144 | + Twitter |
| 145 | + </a> |
| 146 | + | |
| 147 | + <a href="https://docs.medusa-commerce.com"> |
| 148 | + Docs |
| 149 | + </a> |
| 150 | +</p> |
0 commit comments