forkkit / medusa-extender

:syringe: Medusa on steroid. Badass modules, extends Typeorm entities and repositories, medusa core services and so on. Get the full power of modular architecture. Keep your domains clean. Build shareable modules :rocket:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Medusa-extender logo

medusa-extender

Downloads per month NPM Version Dependencies Contributors Awesome medusajs Documentation Twitter Discord Npm download Activity Issues Licence Contributing Test pipeline status Page build deployment status CodeQL security analysis status Product hunt

πŸ’‰ Medusa on steroid. Extends Typeorm entities and repositories, medusa core services and so on. Get the full power of modular architecture. Keep your domains clean. Build shareable modules πŸš€
Do you want to extend existing entities to add custom fields? Do you want to implement your own feature or extend existing one in a module way? Did you ever wanted to build something more than a single store? Well, this project has been made to help you reach you goal. It is now possible to customise Medusa in a way you will be able to enjoy all the awesome features that Medusa provides you but with the possibility to take your e-commerce project to the next level πŸš€


Buy Me A Coffee

-----------------------------------------------------

Table of Contents

-----------------------------------------------------

Getting started πŸš€

IMPORTANT! Using the extender does not break any features from medusa under the hood. The only thing it provides are some badass features

Run the following command in your terminal (The last version is 1.4.5)

npm install medusa-extender

-----------------------------------------------------

Integration within your medusa project

To benefit from all the features that the extender offers you, the usage of typescript is recommended. If you have already an existing project scaffold with the command medusa new ... here is how are the following steps to integrate the extender in your project.

follow the next steps yo be ready to launch πŸš€

npm i -D typescript
echo '{
  "compilerOptions": {
    "module": "CommonJS",
    "declaration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "target": "es2017",
    "sourceMap": true,
    "skipLibCheck": true,
    "allowJs": true,
    "outDir": "dist",
    "rootDir": ".",
    "esModuleInterop": true
  },
  "include": ["src", "medusa-config.js"],
  "exclude": ["dist", "node_modules", "**/*.spec.ts"]
}' > tsconfig.json

update the scripts in your package.json

{
  "scripts": {
    "build": "rm -rf dist && tsc",
    "start": "npm run build && node dist/src/main.js"
  } 
}

add a main file in the src directory

// src/main.ts

import express = require('express');
import { Medusa } from 'medusa-extender';
import { resolve } from 'path';

async function bootstrap() {
    const expressInstance = express();
    
    const rootDir = resolve(__dirname) + '/../';
    await new Medusa(rootDir, expressInstance).load([]);
    
    expressInstance.listen(9000, () => {
        console.info('Server successfully started on port 9000');
    });
}

bootstrap();

And finally update the develop.sh script with the following

#!/bin/bash

#Run migrations to ensure the database is updated
medusa migrations run

#Start development environment
npm run start

-----------------------------------------------------

Features 🧐

-----------------------------------------------------

Non exhaustive list

Here is a list of the features that you can find in that package

  • Create or extend an entity
  • Create or extend a repository
  • Create or extend a service
  • Create middleware before or after medusa authentication strategy
  • Create new migrations
  • Create new router handler
  • Extend validators from medusa to includes custom fields
  • Emit entity subscribers events
  • Listen to entity subscribers and handle them wherever you want

All those features provide you a way to

  • Create and manage a market place
  • Create a media store to sell nft - video - images - keys - etc.
  • And basically create whatever you want on top of @medusajs

Share your code

  • Build shareable modules/plugins to use across your project or to share with the community

-----------------------------------------------------

Architecture

Using this package also allow you to manage your architecture as you want. you will not be limited by any constraint as long as the component are decorated and the modules are referenced into the main file to be loaded, everything is fine. That means that you can go for a modular architecture and decoupled your code depending on your domains.

Here is the proposed folder structure that you can add to your medusa project

.
β”œβ”€β”€ ...
β”œβ”€β”€ src                                 # Here are located all the files that make your application
β”‚   β”œβ”€β”€ modules                         # Where you can put all your modules using the medusa-extender
|       β”œβ”€β”€ Module1
|           β”œβ”€β”€ module1.entity.ts
|           β”œβ”€β”€ module1.migration.ts
|           β”œβ”€β”€ module1.service.ts
|           β”œβ”€β”€ module1.repository.ts
|           β”œβ”€β”€ module1.middleware.ts
|           β”œβ”€β”€ module1.module.ts       # This is where the above components are referenced
|           β”œβ”€β”€ ...
|       β”œβ”€β”€ Module2
|           β”œβ”€β”€ ...
|       β”œβ”€β”€ Module3
|           β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ main.ts                         # this is where the magic happen and your modules will be passed to the load method
└── ...

-----------------------------------------------------

Documentation

See our dedicated documentation website for the Medusa-extender package, follow the link

-----------------------------------------------------

Discussions

If you are interesting in participate to any discussions you can follow that links

-----------------------------------------------------

Resources

Here are some resources that are using the medusa-extender, more of them will come in time πŸš€.

Marketplace tutorial

Here is a tutorial repository that will be followed by a series of article to guide you through the process of creating your marketplace using @medusajs and the medusa-extender.

Here is the link to the Marketplace tutorial repo and Here is the link to the Marketplace tutorial plugin

Here is the first tutorial using the medusa-extender package, Open source ecommerce platform for multi-vendor marketplaces

-----------------------------------------------------

Like my work? πŸ’“

This project needs a ⭐ from you. Don't forget to leave a star ⭐. If you found the package helpful consider supporting me with a coffee

Buy Me A Coffee

-----------------------------------------------------

Contribute

Contributions are welcome! You can look at the contribution guidelines

About

:syringe: Medusa on steroid. Badass modules, extends Typeorm entities and repositories, medusa core services and so on. Get the full power of modular architecture. Keep your domains clean. Build shareable modules :rocket:

License:MIT License


Languages

Language:TypeScript 88.5%Language:JavaScript 7.6%Language:HTML 3.8%Language:Shell 0.1%