GithubHelp home page GithubHelp logo

adrien2p / medusa-extender Goto Github PK

View Code? Open in Web Editor NEW
307.0 307.0 36.0 34.35 MB

:syringe: Medusa on steroid, take your medusa project to the next level with some badass features :rocket:

Home Page: https://adrien2p.github.io/medusa-extender/

License: MIT License

TypeScript 93.62% JavaScript 6.31% Shell 0.07%
architecture cli dynamic-module e-commerce ecommerce extension headless javascript medusa medusa-plugin medusa-plugins medusajs monitoring multi-tenancy nodejs open-source prometheus typeorm typescript

medusa-extender's Introduction

visitors sponsor

Typing SVG

Hi, I'm Adrien2p

Twitter header - 1

A few things about me

  • ๐Ÿ’ป I'm a senior software engineer
  • ๐Ÿ“ I'm from France
  • ๐Ÿ•ธ๏ธ I am passionate about tech and astrophysics
  • ๐Ÿค I like to meet new people
  • ๐Ÿค“ I like to learn about new tech

๐Ÿ“ซ How to reach me?

visitors visitors

๐Ÿ“ˆ GitHub Stats


medusa-extender's People

Contributors

adevinwild avatar adrien2p avatar anup-a avatar dependabot[bot] avatar dwene avatar juanzgc avatar max-prokopenko avatar medusanick avatar sgfgov avatar vkislichenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

medusa-extender's Issues

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

[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

[BUG] Move the migration loader after medusa database loader

The migration loader should run after medusa database in order to keep the right order.
To resolve that, move the migration loader into the database loader after the originalDatabaseLoader such as

const databaseLoader = await import('@medusajs/medusa/dist/loaders/database');
const originalDatabaseLoader = databaseLoader.default;
databaseLoader.default = async ({ container, configModule }) => {
    await entitiesLoader(entities, container);
    await repositoriesLoader(repositories, container);
    const connection = originalDatabaseLoader({ container, configModule });
    /* Here the migration loader */
    return connection;
};

[BUG] TYPO in filename

Describe the bug
A clear and concise description of what the bug is.
The file contants.ts should be constants.ts
To Reproduce
Steps to reproduce the behavior:

  1. Go to 'src folder'

Expected behavior
A clear and concise description of what you expected to happen.
Filename should be 'constants.ts'
Screenshots
If applicable, add screenshots to help explain your problem.

Package version:

  • Version [1.08]

Additional context
Add any other context about the problem here.

Multi-tenant 2

Multi-tenant 2
I am interested in working on Multi-tenant 2 which is mentioned in this image.

Can anyone guide me on where to start?

[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? :)

Service Type Error

Describe the bug
I keep getting type errors when I create a custom service. This happens when import { StoreService as MedusaStoreService } from "@medusajs/medusa/dist/services";. Seems like the types exist on medusa-interfaces because importing import { BaseService as MedusaStoreService } from "medusa-interfaces"; get rid of the errors

To Reproduce
Steps to reproduce the behavior:

  1. Follow the Create Marketplace Tutorial part 1
  2. The store.service and user.service throws the following errors

Expected behavior
Normally, we should not get any type Error, except I am doing something wrong

Screenshots

Screenshot from 2022-08-21 15-38-03

Screenshot from 2022-08-21 15-38-28

Screenshot from 2022-08-21 15-38-39

Package version:

  • Version 1.7.4

Additional context

# medusa versions
"@medusajs/medusa": "^1.3.5",
"@medusajs/medusa-cli": "^1.3.1",

[BUG] Conflicting migration names with using .migration.ts

Describe the bug
I create a migration with the normal structure of modules/:module_name/migrations/:module_name.migration.ts, annotate it with @migration, and import it into the module. When I try to run medex migrate --run, it fails with a duplicate migration detected error

To Reproduce
Steps to reproduce the behavior:
Create a migration in a module, and name it anything-you-want.migration.ts
Create the migration following medusa-extender documentation.
yarn build into a dist folder to compile typescript to javascript.
try running medex migrate --run. Notice you will get an error like this:

UnhandledPromiseRejectionWarning: Error: Duplicate migrations: addIsRecurringToDiscount1651767613018
    at MigrationExecutor.checkForDuplicateMigrations (/Users/derekwene/src/nibll/nibll-home/apps/home/api-medusa/node_modules/typeorm/migration/MigrationExecutor.js:546:19)
    at MigrationExecutor.getMigrations (/Users/derekwene/src/nibll/nibll-home/apps/home/api-medusa/node_modules/typeorm/migration/MigrationExecutor.js:538:14)
    at MigrationExecutor.<anonymous> (/Users/derekwene/src/nibll/nibll-home/apps/home/api-medusa/node_modules/typeorm/migration/MigrationExecutor.js:220:46)
    at step (/Users/derekwene/src/nibll/nibll-home/apps/home/api-medusa/node_modules/tslib/tslib.js:143:27)
    at Object.next (/Users/derekwene/src/nibll/nibll-home/apps/home/api-medusa/node_modules/tslib/tslib.js:124:57)
    at fulfilled (/Users/derekwene/src/nibll/nibll-home/apps/home/api-medusa/node_modules/tslib/tslib.js:114:62)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Expected behavior
The migrations are run without error

Screenshots
image

Workaround:
Now change the name of your migration file to anything-you-want-migration.ts. Compile the typescript and notice it runs the migration fine now.

Package version:

  • Version 1.7.0

Additional context
Add any other context about the problem here.

[chore] Remove swc related

Remove swc support since the project is not that big in the end

  • Remove swc packages
  • Update package.json scripts
  • Merge build:ts/build:declaration script

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

[BUG] medex init command generates faulty example.services.ts file

Describe the bug
The service file created by the init command has an error while compiling. The "exampleServic" is not a variable but rather a string that has a typo. The string should be "exampleService".

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project with the init command using the cli
  2. example.service.ts
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

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

image

Package version:

  • 1.6

Additional context
Add any other context about the problem here.

Register Fulfillment (and other special) services with @Service annotation

It would be nice to be able to register FulfillmentServiceProviders using the Medusa-Extender modules.

In the vanilla Medusa plugin setup, Medusa checks to see if the service is an instance of BaseFulfillmentService during startup to know to register that provider as a normal service or as a fulfillment provider. But when annotating that same service using Medusa-Extender, it doesn't use the same logic to check the base service type. All services are just registered as their name.

Seems like it wouldn't be too hard to clone the Medusa code that registers those services right?

[Doc] Migrations

Looks good! I would suggest you add a note in the documentation that the previously used cliMigrationsDirs is now deprecated and will be overriden by cli_migration_dirs if itโ€™s supplied. from shahed

[Feature] Dynamic module loading

This feature enables to register component dynamically depending on the configModule or some external api call (maybe to check if the user can access some features)

This feature is resolve by this commit

[BUG] Cannot able to update a value in a custom field for an existing module `Customer`

Hi All,
I am using medusa-extender, adding a new column rest_id in customer entity.
Customer.entity.ts

import { Entity as MedusaEntity } from "medusa-extender";
import { Customer as MedusaCustomer } from "@medusajs/medusa";
import { Column, Entity, Index } from "typeorm";

@MedusaEntity({ override: MedusaCustomer })
@Entity()
export class Customer extends MedusaCustomer {
  @Index()
  @Column({ nullable: false })
  rest_id: string;
}

Trying to add rest_id before, whenever the new customer is created. so in the customer.service.ts

@Service({override: MedusaCustomerService})
export default class CustomerService extends MedusaCustomerService {

    private readonly manager: EntityManager;
    private readonly customerRepository: typeof CustomerRepository;
    private readonly addressRepository: typeof AddressRepository;

    constructor(private readonly container: ConstructorParams) {
        super(container);
        this.manager = container.manager;
        this.customerRepository = container.customerRepository;
        this.addressRepository = container.addressRepository;

        CustomerSubscriber.attachTo(container.manager.connection)
    }

    @OnMedusaEntityEvent.Before.Insert(Customer, { async: true })
    public async attachRestaurantToCustomer(
        params: MedusaEventHandlerParams<Customer, 'Insert'>
    ): Promise<EntityEventType<Customer, 'Insert'>> {
        console.log("______________________");
        
        console.log(params.event.entity.rest_id);
        params.event.entity.rest_id = params.event.entity.rest_id || "";
        return params.event;
    }
}

After the customer creation, when I check the database, rest_id is null. the extended field's value is not updating.

Please help me out here.. !!! ๐Ÿ˜ฐ

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:
  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

[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',

[BUG]: module loader: decorated and dynamic modules

Describe the bug
when decorated and dynamic modules are loaded together presenting InjectableOptions with intersecting ComponentTypes - only entries from last one is used

To Reproduce
Steps to reproduce the behavior:

  1. load 2 or more modules that inject services and one of the modules is decorated and another one is dynamic
  2. only services from decorated module will be actually loaded

Expected behavior
All services are loaded

Additional context
Fix in PR #133

[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();
  }
}

[Feature] Add an Omit utility

The Omit util should looks like

const Omit = <T, K extends keyof T>(Class: new () => T, keys: K[]): new () => Omit<T, typeof keys[number]> =>
  Class;

And then can be used like

class MyClass extends Omit(MedusaUser, [โ€˜userRolesโ€™]) {}

[Feature] Integrate nextAuth.js

Is your feature request related to a problem? Please describe.

The medusa core does not allow to integrate different auth strategy at the moment.
It is also not possible to integrate a plugin for that purpose due to how auth works.

Describe the solution you'd like

Being able to choose between different Authentication strategy

To achieve that

  • override the actual auth middleware from medusa to skip internal medusa auth strategy
  • attach nextAuth to the underlying http framework
  • attach the loggedInUser to the request as expected by medusa

[BUG] new endpoint prefixed with /store by-passes even without auth header(cookie: connect.sid)

Describe the bug
On creating new endpoint prefixed with /store (/store/products/prod_01GD2JEGN6A7NBVWXCFE3Y2K4H/reviews), despite configuring requireAuth as true the api call without any type of authentication header (eg cookie: connect.sid) is still passing and executes the whole function where as just changing from /store to /admin (/admin/products/prod_01GD2JEGN6A7NBVWXCFE3Y2K4H/reviews) it works as expected and gives unauthorized (401) response.

To Reproduce
Steps to reproduce the behavior:

  1. create new endpoint prefixed with /store (or anything other than /admin), keep requireAuth as true
  2. start the service, call from postman without any auth header eg
  3. it'll still execute the request

Expected behavior
when any auth header eg (Cookie:connect.sid=s%3APtvXLoUjw3pG_KRKqlSgoH139byEOP9j.I58Wq7uslQe9KXWF8VpbeUv%2BAlS6fG4a8XaHCnUH8cY) isn't sent in the request for the endpoint that configured with requireAuth as true, system should respond with unauthorized.
this works as expected when the endpoint is starting with /admin

Screenshots
please notice the header in both the cases
/store
Screenshot 2022-10-13 at 1 01 21 AM

/admin
Screenshot 2022-10-13 at 1 02 52 AM

Package version:

  • Version [1.7.6]
  • "medusa-extender": "^1.7.6",

Additional context
along with router, its the same behavior with middleware as well

[Feature] multi-tenancy design

As a user, I would like to be able to run an instance of the app and being able to switch the database in use depending on the domain

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?

Fulfillment Provider/Service

Is your feature request related to a problem? Please describe.
I am trying to add a custom Fulfillment Provider and have created the service, but it only gets registered as a service and not a fulfillment provider. When attempting to use the fulfillment provider on a region or shipping profile I get Error: Fulfillment provider not found.

I don't see any documentation and looking at the source code, I don't see any logic for registering the fulfillment service.

Is there a recommended solution?

Describe the solution you'd like
If a service is an instanceof FulfillmentService it should also get registered as a fulfillment provider, similar to medusa's plugin loader. I'm assuming something could be done similar to entities.loader.ts to call registerAdd?

Describe alternatives you've considered
I attempted to manually register the provider after module loading in main.ts like:

const medusa = await new Medusa(
    resolve(__dirname, '..'),
    expressInstance
).load([
    ...custom modules...
]);

medusa.registerAdd(
    'fulfillmentProviders',
    asFunction((cradle) => new MyCustomFulfillmentService(cradle, {}), {
        lifetime: 'SINGLETON',
    })
);

let fulfilProviders;
try {
    fulfilProviders = medusa.resolve('fulfillmentProviders');
} catch {
    fulfilProviders = [];
}
    
await medusa.resolve<FulfillmentProviderService>(
    'fulfillmentProviderService'
).registerInstalledProviders(
    fulfilProviders.map((p) => p.getIdentifier())
);

expressInstance.listen(PORT, () => {
    console.info(`Server successfully started on port ${PORT}`);
});

But I still get the Error: Fulfillment provider not found message. I wIll try a custom service overriding FulfillmentProviderService or create the fulfillment service as a local plugin to see if that fixes the issue in the meantime.

[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

[BUG] Init command

To Reproduce
Steps to reproduce the behavior:
Run command: medex init

Screenshots
Screen Shot 2022-08-14 at 03 14 29

Package version:
"@medusajs/medusa": "^1.3.4",
"@medusajs/medusa-cli": "^1.3.1",
"medusa-extender": "^1.7.4",

[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.

[BUG] Dependency Upgrade to medusa 1.4.X

Describe the bug
A clear and concise description of what the bug is.
The current version is locked to medusa 1.3.X,

Expected behavior
Seemlessly update to use the new medusa version
Screenshots

[Tests] Integration tests

The idea is to start implementing the integration tests in order to avoid regression (or at least see them) when medusa version increase

Also include strategy to run the test for nodejs version 14, 15, 16

[BUG] Server not starting: Cannot read property 'port' of undefined

Describe the bug
The maint.ts do not default to a port number when a custom port is not specified in medusa-config. This error is specific to the projects created using the cli.

(node:5416) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'port' of undefined
    at bootstrap (<PATH TO PROJECT>\dist\main.js:13:48)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5416) 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:5416) [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.

To Reproduce
Steps to reproduce the behavior:

  1. Run...
  2. See error

Expected behavior
The server should have a default port to run the application.

Screenshots

Package version:

  • 1.6

Additional context
Not specified in docs to update config file to add a port number.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.