Medusa and Module Container Resources

This reference provides the list of resources registered in the Medusa container and module containers.

Medusa Container Resources#

The following table lists all resources that you can resolve in your customizations outside a module (such as API routes, workflows, subscribers, and scheduled jobs).

Note: Refer to the Medusa Container documentation for more information on how to use these resources.
Tip: You can use the ContainerRegistrationKeys enum imported from @medusajs/framework/utils where specified.

Resource

Description

Registration Name

Medusa Configurations

The configurations defined in medusa-config.ts.

configModule or ContainerRegistrationKeys.CONFIG_MODULE

Logger

Utility to log messages to the terminal.

logger or ContainerRegistrationKeys.LOGGER

Query

Query to retrieve data across modules.

query or ContainerRegistrationKeys.QUERY

Link

Manage links between records of two modules' data models.

link or ContainerRegistrationKeys.LINK

Modules' main services

The main service of every module added in medusa-config.ts.

  • For custom modules, the registration name is the first parameter of Module exported in the index.ts file of the module.
  • For Medusa's Commerce and Infrastructural Modules, use the Modules enum imported from @medusajs/framework/utils.

Module Container Resources#

The following table lists all resources that you can resolve in a module's services or loaders.

Note: Refer to the Module Container documentation for more information on how to use these resources.
Note: Use the ContainerRegistrationKeys and Modules enums imported from @medusajs/framework/utils where specified.

Resource

Description

Registration Name

Logger

Utility to log messages to the terminal.

logger or ContainerRegistrationKeys.LOGGER

Entity Manager

An instance of MikroORM's entity manager.

manager or ContainerRegistrationKeys.MANAGER

Base Repository

An instance of the base repository, used to run transactions and perform database operations.

baseRepository

Medusa Configurations

The configurations defined in medusa-config.ts.

configModule or ContainerRegistrationKeys.CONFIG_MODULE

Event Module's service

The service of the Event Module, used to emit events.

event_bus or Modules.EVENT_MODULE

Services generated by the service factory

The service of every data model passed to the MedusaService function that your module's service extends. The service has the methods described in the service factory reference.

Each service is registered as the camel-cased name of the data model. For example:

  • Brand data model's service is registered as brandService.
  • DigitalProduct data model's service is registered as digitalProductService.

Module services

You can resolve the module's services from one another, but not in loaders. Learn more in the Module Container documentation.

Each service is registered as the camel-cased name of the service. For example:

  • BrandModuleService is registered as brandModuleService.
  • CmsService is registered as cmsService.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break