Skip to content

Latest commit

 

History

History
82 lines (56 loc) · 1.93 KB

File metadata and controls

82 lines (56 loc) · 1.93 KB

Medusa v2 Example: Loyalty Points System

This directory holds the code for the Loyalty Points System Tutorial.

You can either:

Prerequisites

Installation

  1. Clone the repository and change to the loyalty-points directory:
git clone https://github.com/medusajs/examples.git
cd examples/loyalty-points

2. Rename the .env.template file to .env.

3. If necessary, change the PostgreSQL username, password, and host in the DATABASE_URL environment variable.

4. Install dependencies:

yarn # or npm install

5. Setup and seed the database:

npx medusa db:setup
yarn seed # or npm run seed

6. Start the Medusa application:

yarn dev # or npm run dev

Refer to the More Resources for OpenAPI Specs of custom API routes.

Copy into Existing Medusa Application

If you have an existing Medusa application, copy the following directories and files into your project:

  • src/api/store
  • src/modules/loyalty
  • src/subscribers
  • src/utils
  • src/workflows

Then, add the Loyalty Module to medusa-config.ts:

module.exports = defineConfig({
  // ...
  modules: [
    {
      resolve: "./src/modules/loyalty",
    }
  ],
})

Finally, run migrations:

npx medusa db:migrate

More Resources