Medusa on steroid, take your medusa project to the next level with some badass features πŸš€

Overview

Medusa-extender logo

medusa-extender

Full documentation website

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 Codacy code quality Product hunt

Medusa on steroid, take your medusa project to the next level with some badass features πŸš€
The extender provides an out-of-the-box application architecture which allows developers and teams to create highly testable, scalable, loosely coupled, and easily maintainable applications. In also increase medusa extensibility and customisation for special use cases. It comes with handy decorators approach to increase the DX and full typings support for easier development. It is a complement to medusa but not a replacement πŸš€


Buy Me A Coffee

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

Table of Contents

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

Introduction

Medusa is an open source headless commerce platform that allows you to create your own store in a matter of minutes. Part of what makes Medusa a good choice for your ecommerce store is its extensibility. Now, it is also possible to create multi-vendor marketplaces using Medusa.

πŸ‘‰ And here is why I've done that package for medusa

"I've been looking for an e-commerce solution that could provide me with some core features while being fully customisable... After some research, where I found that none of the present solutions could provide what I needed, I chose Medusa as it provided me with many of the needed features while being easy to extend. I ended up loving the community atmosphere, especially the proximity with the team, and have been helping those in the community looking for a similar fully-customisable solution by sharing a part of my private project. This is how the medusa-extender was born." β€” Adrien de Peretti

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

Getting started πŸš€

Depending on your situation, pick the right getting started section.

Existing medusa project

In that case, you must already have scaffold a new medusa store project. If that's not the case you can follow the tutorial here.

Run the following command in your terminal

npm install medusa-extender
./node_modules/.bin/medex init

That's it, you are now ready to run your server πŸš€

Note: The default port is 9000, if you want to run the server on a custom port update medusa-config.js as follows:

module.exports = {
  /* ... */
  serverConfig:{
    port: 
  }
  /* ... */
};

From server starter

You can directly clone the starters/server to get started quickly.

First, update your medusa-config.js accordingly to your needs.

Then, follow the next command to be ready in minutes

npx degit github:adrien2p/medusa-extender/starters/server#main server
cd server
npm i
npm run build
npm run start

That's it, your server is now up and running πŸš€

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

CLI medex

To install the cli globally instead of using the local one, you can run the following command

npm i -g medusa-extender

To make things easier for you, the project comes with a CLI that allow you to generate any component with minimum code implementation and also to be able to run the migrations and show the list of applied and to be applied migrations.

To see more about the usage and references, click here to see the documentation

Application Architecture

Using this package help you organise your code in a module approach. 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
└── ...

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

Discussions

If you are interesting to participate in 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

Comments
  • [BUG] Failed to build From server starter

    [BUG] Failed to build From server starter

    Failed to build

    To Reproduce Steps to reproduce the behavior:

    npx degit github:adrien2p/medusa-extender/starters/server#main server
    cd server
    npm i
    npm run build
    npm run start
    
    Initializing databasenode:internal/process/promises:265
                triggerUncaughtException(err, true /* fromPromise */);
                ^
    
    Error: getaddrinfo ENOTFOUND undefined
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
      errno: -3008,
      code: 'ENOTFOUND',
      syscall: 'getaddrinfo',
      hostname: 'undefined'
    }
    

    on Ubuntu 18 LTS

    • npm: '8.3.1',
    • node: '16.14.0',
    • v8: '9.4.146.24-node.20',
    help wanted 
    opened by swarmlab-hybrid 17
  • [Feature] Migrate command for multi tenancy

    [Feature] Migrate command for multi tenancy

    Is your feature request related to a problem? Please describe. Currently the migrate command is only respecting the projectConfig database. If youre using multi tenancy, this is kinda shitty, cause you need to migrate every tenant database manually. For this you need to change projectConfig manually to every tenant. if youve alot tenants, this is painful as f....

    Describe the solution you'd like Make the migration command also possible for multi_tenancy settings

    Describe alternatives you've considered There is none. If the config defines an enabled multi_tenancy, migration should run everywhere, maybe with flag

    Additional context Please? :)

    enhancement 
    opened by Inoir 8
  • [BUG] In the loggedInUser.middleware req.user is missing

    [BUG] In the loggedInUser.middleware req.user is missing

    Error:

    Resolution path: loggedInUser
    AwilixResolutionError: Could not resolve 'loggedInUser'.
    

    When I checked, req.user is not coming in the loggedInUser middleware.

    Middleware code:

    import {
      MedusaAuthenticatedRequest,
      MedusaMiddleware,
      Middleware,
    } from "medusa-extender";
    import { NextFunction, Response } from "express";
    
    import UserService from "./user.service";
    
    @Middleware({ requireAuth: true, routes: [{ method: "all", path: "*" }] })
    export class LoggedInUserMiddleware implements MedusaMiddleware {
      public async consume(
        req: MedusaAuthenticatedRequest,
        res: Response,
        next: NextFunction
      ): Promise<void> {
    
        if (req.user && req.user.userId) {
          const userService = req.scope.resolve('userService') as UserService;
          const loggedInUser = await userService.retrieve(req.user.userId, {
            select: ['id', 'store_id'],
          });
    
          console.log(req.user);
    
    
          req.scope.register({
            loggedInUser: {
              resolve: () => loggedInUser,
            },
          });
        }
        next();
      }
    }
    
    question 
    opened by bibekkakati 8
  • AwilixResolutionError: Could not resolve 'authService'.

    AwilixResolutionError: Could not resolve 'authService'.

    Describe the bug When I try to run the docker image of my medusa app it is failing on AwilixResolutionError: Could not resolve 'authService'.

    {"activity_id":"01GANBHPAKPBT7TR68TPPXW5VX","duration":1025,"level":"info","message":"Database initialized","timestamp":"2022-08-17 07:33:38"} jungle-server-default | {"activity_id":"01GANBHQANZY3J22FP0K1XMBRX","config":{},"level":"info","message":"Initializing strategies","timestamp":"2022-08-17 07:33:38"} jungle-server-default | {"activity_id":"01GANBHQANZY3J22FP0K1XMBRX","duration":1,"level":"info","message":"Strategies initialized","timestamp":"2022-08-17 07:33:38"} jungle-server-default | {"activity_id":"01GANBHQAQYAW8PSPAJ6CJPFV3","config":{},"level":"info","message":"Initializing services","timestamp":"2022-08-17 07:33:38"} jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - UserService jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - ProductService jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - OrderService jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - StoreService jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] Service overridden - InviteService jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] 0 services registered jungle-server-default | [Server] - 8/17/2022, 7:33:38 AM [ServicesLoader] 5 services overridden jungle-server-default | {"activity_id":"01GANBHQAQYAW8PSPAJ6CJPFV3","duration":4,"level":"info","message":"Services initialized","timestamp":"2022-08-17 07:33:38"} jungle-server-default | {"activity_id":"01GANBHQAWVZ6141F3XCPQ61HF","config":{},"level":"info","message":"Initializing express","timestamp":"2022-08-17 07:33:38"} jungle-server-default | /app/jungle/node_modules/@medusajs/medusa/node_modules/awilix/lib/container.js:240 jungle-server-default | throw new errors_1.AwilixResolutionError(name, resolutionStack); jungle-server-default | ^ jungle-server-default | jungle-server-default | AwilixResolutionError: Could not resolve 'authService'. jungle-server-default | jungle-server-default | Resolution path: authService jungle-server-default | at Object.resolve (/app/jungle/node_modules/@medusajs/medusa/node_modules/awilix/lib/container.js:240:23) jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:51:37 jungle-server-default | at step (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:33:23) jungle-server-default | at Object.next (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:14:53) jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:8:71 jungle-server-default | at new Promise () jungle-server-default | at __awaiter (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:4:12) jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/passport.js:48:12 jungle-server-default | at /app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:161:65 jungle-server-default | at step (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:52:23) jungle-server-default | at Object.next (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:33:53) jungle-server-default | at fulfilled (/app/jungle/node_modules/@medusajs/medusa/dist/loaders/index.js:24:58) jungle-server-default | at processTicksAndRejections (node:internal/process/task_queues:96:5) jungle-server-default | jungle-server-default | Node.js v17.1.0

    To Reproduce Steps to reproduce the behavior:

    1. Configure your dockerfile and docker-compose.yml
    2. Run docker compose -f docker-compose.yml up --build
    3. See error

    Expected behavior Server should successfully start

    Screenshots

    Package version: Ubuntu 20.04 postgres: 14 node 17.1.0 npm@latest "@medusajs/medusa": "^1.3.1", "@medusajs/medusa-cli": "^1.3.0", "@types/jsonwebtoken": "^8.5.8", "awilix": "4.2.3", "medusa-extender": "^1.7.2", "medusa-file-minio": "^1.0.4", "medusa-fulfillment-manual": "^1.1.26", "medusa-interfaces": "^1.3.0", "medusa-payment-manual": "^1.0.8", "medusa-payment-stripe": "^1.1.30", "mongoose": "^5.13.3", "typeorm": "^0.2.45" "@babel/cli": "^7.14.3", "@babel/core": "^7.14.3", "@babel/preset-typescript": "^7.14.5", "babel-preset-medusa-package": "^1.1.13", "nodemon": "^2.0.15", "ts-node": "^10.7.0", "typescript": "^4.5.5"

    Additional context The error is not occuring in development outside docker container /app/jungle is my docker workdir

    opened by Wingrammer 6
  • [Feature]  Security enhancement for multi-tenancy

    [Feature] Security enhancement for multi-tenancy

    Storing sensitive information like database credentials in plain text format on a database can lead to a disastrous chain of events.

    I suggest to store them in medusa-config.js.

    opened by xc0d3rz 6
  • Extending product entity

    Extending product entity

    Hi, I have a question about extension of Product entity. I extended the product entity with one more field I checked the database and the field was successfully added. My question is how can I access the extended product service? I defined custom route where I tried to use productService through the scope but I didn't see my extended column. Can you help me with that? thanks in advance

    opened by pelonidas 5
  • Proper Documentation request for Multitenancy feature

    Proper Documentation request for Multitenancy feature

    Is your feature request related to a problem? Please describe. I followed the doc for multitenancy where it's mentioned to set up the config but nothing is said about how we can configure the tenant for the store. I could also see that Multi-tenant 1 is mentioned so how to configure db for each tenant?

    opened by vedraiyani 5
  • [BUG] Cannot override relation with Omit

    [BUG] Cannot override relation with Omit

    Describe the bug I want to override countries to ManyToMany. But it didn't work, I have to create a new field country_list instead to pass this case

    MedusaRegionEntity
    
    @Entity()
    export class Region extends SoftDeletableEntity {
        @OneToMany(() => Country, (c) => c.region)
         countries: Country[]
    }
    
    MedusaExRegionEntity
    
    @MedusaEntity({ override: MedusaRegion })
    @Entity()
    export class Region extends Omit(MedusaRegion, ["countries"]) {
    
      @ManyToMany(() => Country, (country) => country.regions, {
        cascade: true,
      })
      @JoinTable({
        name: "region_country",
        joinColumn: {
          name: "region_id",
          referencedColumnName: "id",
        },
        inverseJoinColumn: {
          name: "country_id",
          referencedColumnName: "id",
        },
      })
      countries: Country[];
    }
    
    
    opened by lnquy065 4
  • [BUG] Multi tenancy on default setup doesnt work

    [BUG] Multi tenancy on default setup doesnt work

    Describe the bug Currently the multi tenancy on default setup of the project does not work. Mostly caused of the behaviour medusa is loading the configModule and strips off all custom props. Since the TenantService is using the resolved configModule from the container, there is no multi_tenancy config in the one provided in the tenant service.

    Other point why its not working is the TenantService itself does not get registered anymore. I only got it working with own module and importing the service and middleware there. So seems something is wrong in the module, but couldnt figure out. ( Just looked into the code and seems same issue as in TenantService, module uses the configModule resolved from container, so no multi_tenancy options in there)

    To Reproduce Steps to reproduce the behavior:

    1. Checkout new medusa-extender proj
    2. Configure multi tenancy and use the tenant module
    3. Try make a request to some tenant products (i.e list products)
    4. Error is thrown cause either tenantService couldnt be resolved (first issue) or Error is thrown cause of multi_tenancy options not set in the configModule loaded in the TenantService

    Expected behavior Should work

    Screenshots Screenshot 2022-09-30 at 13 59 08

    Package version: medusa-extender: 1.7.6 medusa: 1.4.1

    opened by Inoir 4
  • [BUG] init command

    [BUG] init command

    Hi,

    When i trying to launch the following command:

    This error appears:

    ./node_modules/.bin/medex init
    [MEDEX-CLI]      - 8/23/2022, 8:21:18 AM   [Init command] Initialising medusa-extender...
    [MEDEX-CLI]      - 8/23/2022, 8:21:18 AM   [Init command] [Packages] Check that the packages are installed
    [MEDEX-CLI]      - 8/23/2022, 8:21:18 AM   [Init command] Installing the necessary packages if they are not already installed
    [MEDEX-CLI]      - 8/23/2022, 8:21:18 AM   [Init command] Installing [email protected]...
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    
    [MEDEX-CLI]      - 8/23/2022, 8:21:24 AM   [Init command] Installing [email protected]...
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    
    [MEDEX-CLI]      - 8/23/2022, 8:21:33 AM   [Init command] Installing [email protected]...
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    
    [MEDEX-CLI]      - 8/23/2022, 8:21:38 AM   [Init command] Packages installed
    [MEDEX-CLI]      - 8/23/2022, 8:21:38 AM   [Init command] [Scripts] Update package.json scripts
    [MEDEX-CLI]      - 8/23/2022, 8:21:38 AM   [Init command] [TsConfig] Create or update tsconfig.json
    [MEDEX-CLI]      - 8/23/2022, 8:21:38 AM   [Init command] [tsconfig.json] Update tsconfig.json
    (node:129438) UnhandledPromiseRejectionWarning: SyntaxError: /home/kereval.com/bcu/perso/lrvlb/la-ruee-vers-le-bois-store/tsconfig.json: Unexpected token } in JSON at position 65
        at parse (<anonymous>)
        at Object.Module._extensions..json (internal/modules/cjs/loader.js:1128:22)
        at Module.load (internal/modules/cjs/loader.js:950:32)
        at Function.Module._load (internal/modules/cjs/loader.js:790:12)
        at Module.require (internal/modules/cjs/loader.js:974:19)
        at require (internal/modules/cjs/helpers.js:101:18)
        at /home/kereval.com/bcu/perso/lrvlb/la-ruee-vers-le-bois-store/node_modules/medusa-extender/dist/cli/commands/init.js:84:61
        at async updateTsconfigJson (/home/kereval.com/bcu/perso/lrvlb/la-ruee-vers-le-bois-store/node_modules/medusa-extender/dist/cli/commands/init.js:84:26)
        at async init (/home/kereval.com/bcu/perso/lrvlb/la-ruee-vers-le-bois-store/node_modules/medusa-extender/dist/cli/commands/init.js:23:5)
        at async Command.<anonymous> (/home/kereval.com/bcu/perso/lrvlb/la-ruee-vers-le-bois-store/node_modules/medusa-extender/dist/cli/index.js:65:5)
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:129438) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:129438) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    Remove the , in tsconfig.json solved the problem

    opened by jtqfaire 4
  • [BUG] Route method is not overriding

    [BUG] Route method is not overriding

    Describe the bug The route method is not overriding, or I'm doing it wrong but can't find anything besides the marketplace example.

    To Reproduce Steps to reproduce the behavior:

    1. You can go and install https://github.com/Giovanny-DS/sharedbackend
    2. Run it, and check that admin/auth is not overriding the handler.
    3. You may also just go and check the auth module code that I did write.

    Expected behavior we should receive a JSON like { user: cleanRes, test: 'test' }

    instead of just { user: cleanRes }

    Screenshots not applicable?

    Package version:

    • Version 1.7.2

    Additional context I think all it's clear, but I can answer any question fast.

    question 
    opened by Giovanny-DS 4
  • chore(deps): bump json5 from 2.2.1 to 2.2.3

    chore(deps): bump json5 from 2.2.1 to 2.2.3

    Bumps json5 from 2.2.1 to 2.2.3.

    Release notes

    Sourced from json5's releases.

    v2.2.3

    v2.2.2

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).
    Changelog

    Sourced from json5's changelog.

    v2.2.3 [code, diff]

    v2.2.2 [code, diff]

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).
    Commits
    • c3a7524 2.2.3
    • 94fd06d docs: update CHANGELOG for v2.2.3
    • 3b8cebf docs(security): use GitHub security advisories
    • f0fd9e1 docs: publish a security policy
    • 6a91a05 docs(template): bug -> bug report
    • 14f8cb1 2.2.2
    • 10cc7ca docs: update CHANGELOG for v2.2.2
    • 7774c10 fix: add proto to objects and arrays
    • edde30a Readme: slight tweak to intro
    • 97286f8 Improve example in readme
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Generate Migration TypeORM

    Generate Migration TypeORM

    Describe the bug Generating a migration results in errors if the Entity that you are overriding has column types of other Entities (that are imported).

    TypeORMError: Entity metadata for Product#images was not found. Check if you specified a correct entity object and if it's connected in the connection options.
        at new TypeORMError (/Users/juan/renlo/node_modules/src/error/TypeORMError.ts:7:9)
        at /Users/juan/renlo/node_modules/src/metadata-builder/EntityMetadataBuilder.ts:687:23
        at Array.forEach (<anonymous>)
        at EntityMetadataBuilder.computeInverseProperties (/Users/juan/renlo/node_modules/src/metadata-builder/EntityMetadataBuilder.ts:682:34)
        at /Users/juan/renlo/node_modules/src/metadata-builder/EntityMetadataBuilder.ts:119:56
        at Array.forEach (<anonymous>)
        at EntityMetadataBuilder.build (/Users/juan/renlo/node_modules/src/metadata-builder/EntityMetadataBuilder.ts:119:25)
        at ConnectionMetadataBuilder.<anonymous> (/Users/juan/renlo/node_modules/src/connection/ConnectionMetadataBuilder.ts:65:111)
        at step (/Users/juan/renlo/node_modules/tslib/tslib.js:144:27)
        at Object.next (/Users/juan/renlo/node_modules/tslib/tslib.js:125:57)
    error Command failed with exit code 1.
    

    For example:

    • Product: [images, options, variants, profile, collection, type, tags, sales_channel]
    • User: []

    Whereas User doesn't face this error because there are no column types of other imported entities.

    It seems that for whatever reason, when generating the migration with extended Entities, typeorm has difficulty with nested imports.

    @medusajs/medusa/dist/models/product.d.ts: image

    @medusajs/medusa/dist/models/user.d.ts: image

    To Reproduce Steps to reproduce the behavior:

    1. Create a ormconfig.json
    {
      "type": "postgres",
      "url": "<INSERT>",
      "synchronize": false,
      "entities": ["dist/modules/**/*.entity.js"],
      "migrations": ["dist/modules/migrations/*.js"],
      "cli": {
        "migrationsDir": "src/modules/migrations"
      }
    }
    
    1. Add the following scripts in package.json:
        "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
        "migration:generate": "yarn typeorm migration:generate",
    
    1. Install typeorm:
    yarn add [email protected]
    
    1. Extend the Product Entity
    import { Column, Entity, Index } from 'typeorm';
    import { Product as MedusaProduct } from '@medusajs/medusa/dist/models';
    import { Entity as MedusaEntity } from 'medusa-extender';
    
    @MedusaEntity({ override: MedusaProduct })
    @Entity()
    export class Product extends MedusaProduct {
      @Index()
      @Column({ nullable: false })
      store_id: string;
    }
    
    1. Generate Migration:
    yarn build
    yarn typeorm migration:generate -n InitialProductMigration
    
    1. You will see the error Entity metadata for Product#images was not found. However, if you add an export to the Product Entity extender you won't see the same error. The error will now be Entity metadata for Product#options was not found.
    import { Column, Entity, Index } from 'typeorm';
    import { Product as MedusaProduct } from '@medusajs/medusa/dist/models';
    import { Entity as MedusaEntity } from 'medusa-extender';
    
    export { Image } from '@medusajs/medusa/dist/models';
    
    @MedusaEntity({ override: MedusaProduct })
    @Entity()
    export class Product extends MedusaProduct {
      @Index()
      @Column({ nullable: false })
      store_id: string;
    }
    

    The line changed was: export { Image } from '@medusajs/medusa/dist/models';

    Don't forget to yarn build before re-attempting to generate the migration.

    TypeORMError: Entity metadata for Product#options was not found. Check if you specified a correct entity object and if it's connected in the connection options.
    

    You can continue adding all the remaining exports until the migration is generated, however, it will also generate a faulty migration because it will include multiple FKs and Indexes that it attempts to delete. I believe if we could somehow move all Entities into one file and export from one file (at build time), we would no longer see these migration errors.

    You can also try this with an easier Entity such as Store which has less Columns that are referenced by other Entities

    Expected behavior Generate a migration without having to go through these hacks to get one generated. Generating migrations in the Medusa Core doesn't have these issues.

    Screenshots If applicable, add screenshots to help explain your problem.

    Package version:

    • Version 1.7.4

    Additional context Similar Issue

    invalid need reproduction 
    opened by juanzgc 14
Releases(v1.8.0)
Owner
Adrien de Peretti
I am just a programmer like any other
Adrien de Peretti
Next-level academia! Repository for the Native Overleaf project, attempting to integrate Overleaf with native OS features for macOS, Linux and Windows.

Native Overleaf Overleaf is a fantastic webtool for writing and cooperating on LaTeX documents. However, would it not be even better if it were to beh

Floris-Jan Willemsen 40 Dec 18, 2022
Medusa + Next.js starter frontend UI project as a part of Open source contribution.

Medusa Next.js Starter Medusa is an open-source headless commerce engine that enables developers to create amazing digital commerce experiences. Prere

Gourav Singh Rawat 9 Dec 15, 2022
Generate random ethereum wallets & private keys and then check if they match a wallet that contains some kind of balance, so that you can take it. In Node.js

Ethereum-Stealer Generate random ethereum wallets & private keys and then check if they match a wallet that contains some kind of balance, so that you

MichaΕ‚ 74 Dec 24, 2022
A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. β“‚πŸ’―

A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. β“‚??

Reem janina 7 May 31, 2022
JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard API using JavaScript async and await and add some styling.

Leaderboard Project JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard

bizimungu pascal 4 May 20, 2022
solana-base-app is a base level, including most of the common features and wallet connectivity, try using `npx solana-base-app react my-app`

solana-base-app solana-base-app is for Solana beginners to get them up and running fast. To start run : run npx solana-base-app react my-app change th

UjjwalGupta49 33 Dec 27, 2022
πŸš€ Final Esports project based on Rocketseat's Next Level Week.

The evolved version of the Esports project on the Next Level Week by Rocketseat. The web client is deployed on Vercel here: https://nlw-esports-ignite

JoΓ£o Martinho 35 Oct 26, 2022
This Repo Contains projects that demonstrate some concepts / algorithms / implemetation in some form of digital visualisation

Hacktoberfest 2022 OPEN FIRST Pull Request - GET STARTED WITH OPENSOURCE AND WIN SOME AWWSOME SWAGS ?? Contributors of Hacktoberfest 2022 This project

null 5 Nov 7, 2022
Some out-of-the-box utility features based on the Oasis engine.

Engine Toolkit Some out-of-the-box utility features based on the Oasis engine Script, welcome to enjoy! Features ?? Controls - Some camera controllers

Oasis 22 Nov 21, 2022
A chrome extension to add some neat features to pulp!

Pulp+ A Chrome extension that extends Pulp with some extra features! Important: This plugin is in no affiliated with Panic. Lot's of the features belo

UnbelievableFlavour 5 Jul 6, 2022
A plugin starter for medusa pre-configured and using typescript

Plugin starter (Typescript) Start to write your own plugin as quick as possible Getting started Installation git clone [email protected]:adrien2p/medusa-

Adrien de Peretti 12 Nov 9, 2022
NX workspace for running medusa backend, storefront and admin panel with marketplace functionalities

Medusa Marketplace Project status Assigned store_id to Order, Product to make them store specific Create and process payment for an order with multipl

Keith Hon 8 Nov 13, 2022
medusa-plugin-webhooks

Medusa Plugin Webhooks About Participants Anish De GitHub: @AnishDe12020 Twitter: @AnishDe12020 Discord: AnishDe12020#8442 (ID: 727047127271735387) De

Anish De 13 Dec 18, 2022
A beautiful NextJS storefront for a Medusa store (The opensource alternative to Shopify)

medusa-starter-monster About Participants Yinka - @yinkakun Description Medusa Storefronts don't have to be boring. This starter is an elegant and bea

Yinka Adedire 12 Dec 16, 2022
Expose top-level identifiers in Next.js app.js

recma-nextjs-static-props Expose top-level identifiers in Next.js app.js Installation npm install recma-nexjs-static-props Usage This plugin is intend

Remco Haszing 14 Nov 3, 2022
Desenvolvimento do projeto Proffy para Web e mobile, na segunda Next Level Week

Tecnologias | Projeto | Layout | Licença ?? Tecnologias Esse projeto foi desenvolvido com as seguintes tecnologias: Node.js React React Native Expo ??

Laciene Alves Melo 2 Jun 12, 2022
Next-level mongoose caching layer with event based cache clearing

SpeedGoose ## About The Project This project is a next-level mongoose caching library which is fully written in typescript. It's caching on two levels

Arkadiusz Gil 17 Dec 15, 2022