1 import { Table } from "docs-ui"
2
3 export const metadata = {
4 title: `Medusa and Module Container Resources`,
5 }
6
7 # {metadata.title}
8
9 This reference provides the list of resources registered in the Medusa container and module containers.
10
11 ## Medusa Container Resources
12
13 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).
14
15 <Note>
16
17 Refer to the [Medusa Container](!docs!/learn/fundamentals/medusa-container) documentation for more information on how to use these resources.
18
19 </Note>
20
21 <Note title="Tip">
22
23 You can use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/utils` where specified.
24
25 </Note>
26
27 <Table>
28 <Table.Header>
29 <Table.Row>
30 <Table.HeaderCell>
31
32 Resource
33
34 </Table.HeaderCell>
35 <Table.HeaderCell>
36
37 Description
38
39 </Table.HeaderCell>
40
41 <Table.HeaderCell>
42
43 Registration Name
44
45 </Table.HeaderCell>
46 </Table.Row>
47 </Table.Header>
48 <Table.Body>
49 <Table.Row>
50 <Table.Cell>
51
52 [Medusa Configurations](!docs!/learn/configurations/medusa-config)
53
54 </Table.Cell>
55 <Table.Cell>
56
57 The configurations defined in `medusa-config.ts`.
58
59 </Table.Cell>
60 <Table.Cell>
61
62 `configModule` or `ContainerRegistrationKeys.CONFIG_MODULE`
63
64 </Table.Cell>
65 </Table.Row>
66
67 <Table.Row>
68 <Table.Cell>
69
70 [Logger](!docs!/learn/debugging-and-testing/logging)
71
72 </Table.Cell>
73 <Table.Cell>
74
75 Utility to log messages to the terminal.
76
77 </Table.Cell>
78 <Table.Cell>
79
80 `logger` or `ContainerRegistrationKeys.LOGGER`
81
82 </Table.Cell>
83 </Table.Row>
84
85 <Table.Row>
86 <Table.Cell>
87
88 [Query](!docs!/learn/fundamentals/query)
89
90 </Table.Cell>
91 <Table.Cell>
92
93 Query to retrieve data across modules.
94
95 </Table.Cell>
96 <Table.Cell>
97
98 `query` or `ContainerRegistrationKeys.QUERY`
99
100 </Table.Cell>
101 </Table.Row>
102
103 <Table.Row>
104 <Table.Cell>
105
106 [Link](!docs!/learn/fundamentals/module-links/link)
107
108 </Table.Cell>
109 <Table.Cell>
110
111 Manage links between records of two modules' data models.
112
113 </Table.Cell>
114 <Table.Cell>
115
116 `link` or `ContainerRegistrationKeys.LINK`
117
118 </Table.Cell>
119 </Table.Row>
120
121 <Table.Row>
122 <Table.Cell>
123
124 Knex
125
126 </Table.Cell>
127 <Table.Cell>
128
129 [Knex query builder](https://knexjs.org/) connected to your application's database. Avoid performing database operations with this query builder and instead use [services](!docs!/learn/fundamentals/modules#2-create-service). This is only available for general database connectivity purposes.
130
131 </Table.Cell>
132 <Table.Cell>
133
134 `__pg_connection__` or `ContainerRegistrationKeys.PG_CONNECTION`
135
136 </Table.Cell>
137 </Table.Row>
138
139 <Table.Row>
140 <Table.Cell>
141
142 Modules' main services
143
144 </Table.Cell>
145 <Table.Cell>
146
147 The main service of every module added in `medusa-config.ts`.
148
149 </Table.Cell>
150 <Table.Cell>
151
152 - For custom modules, the registration name is the first parameter of `Module` exported in the `index.ts` file of the module.
153 - For Medusa's Commerce and Infrastructural Modules, use the `Modules` enum imported from `@medusajs/framework/utils`.
154
155 </Table.Cell>
156 </Table.Row>
157 </Table.Body>
158 </Table>
159
160 ---
161
162 ## Module Container Resources
163
164 The following table lists all resources that you can resolve in a module's services or loaders.
165
166 <Note>
167
168 Refer to the [Module Container](!docs!/learn/fundamentals/modules/container) documentation for more information on how to use these resources.
169
170 </Note>
171
172 <Note>
173
174 Use the `ContainerRegistrationKeys` and `Modules` enums imported from `@medusajs/framework/utils` where specified.
175
176 </Note>
177
178 <Table>
179 <Table.Header>
180 <Table.Row>
181 <Table.HeaderCell>
182
183 Resource
184
185 </Table.HeaderCell>
186 <Table.HeaderCell>
187
188 Description
189
190 </Table.HeaderCell>
191
192 <Table.HeaderCell>
193
194 Registration Name
195
196 </Table.HeaderCell>
197 </Table.Row>
198 </Table.Header>
199 <Table.Body>
200 <Table.Row>
201 <Table.Cell>
202
203 [Logger](!docs!/learn/debugging-and-testing/logging)
204
205 </Table.Cell>
206 <Table.Cell>
207
208 Utility to log messages to the terminal.
209
210 </Table.Cell>
211 <Table.Cell>
212
213 `logger` or `ContainerRegistrationKeys.LOGGER`
214
215 </Table.Cell>
216 </Table.Row>
217
218 <Table.Row>
219 <Table.Cell>
220
221 Entity Manager
222
223 </Table.Cell>
224 <Table.Cell>
225
226 An instance of [MikroORM's entity manager](https://mikro-orm.io/api/knex/class/EntityManager).
227
228 </Table.Cell>
229 <Table.Cell>
230
231 `manager` or `ContainerRegistrationKeys.MANAGER`
232
233 </Table.Cell>
234 </Table.Row>
235
236 <Table.Row>
237 <Table.Cell>
238
239 [Base Repository](!docs!/learn/fundamentals/modules/db-operations#configure-transactions-with-the-base-repository)
240
241 </Table.Cell>
242 <Table.Cell>
243
244 An instance of the base repository, used to run transactions and perform database operations.
245
246 </Table.Cell>
247 <Table.Cell>
248
249 `baseRepository`
250
251 </Table.Cell>
252 </Table.Row>
253
254 <Table.Row>
255 <Table.Cell>
256
257 [Medusa Configurations](!docs!/learn/configurations/medusa-config)
258
259 </Table.Cell>
260 <Table.Cell>
261
262 The configurations defined in `medusa-config.ts`.
263
264 </Table.Cell>
265 <Table.Cell>
266
267 `configModule` or `ContainerRegistrationKeys.CONFIG_MODULE`
268
269 </Table.Cell>
270 </Table.Row>
271
272 <Table.Row>
273 <Table.Cell>
274
275 [Event Module](../infrastructure-modules/event/page.mdx)'s service
276
277 </Table.Cell>
278 <Table.Cell>
279
280 The service of the Event Module, used to emit events.
281
282 </Table.Cell>
283 <Table.Cell>
284
285 `event_bus` or `Modules.EVENT_MODULE`
286
287 </Table.Cell>
288 </Table.Row>
289
290 <Table.Row>
291 <Table.Cell>
292
293 Services generated by the [service factory](../service-factory-reference/page.mdx)
294
295 </Table.Cell>
296 <Table.Cell>
297
298 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](../service-factory-reference/page.mdx).
299
300 </Table.Cell>
301 <Table.Cell>
302
303 Each service is registered as the camel-cased name of the data model. For example:
304
305 - `Brand` data model's service is registered as `brandService`.
306 - `DigitalProduct` data model's service is registered as `digitalProductService`.
307
308 </Table.Cell>
309 </Table.Row>
310
311 <Table.Row>
312 <Table.Cell>
313
314 Module services
315
316 </Table.Cell>
317 <Table.Cell>
318
319 You can resolve the module's services from one another, but not in loaders. Learn more in the [Module Container](!docs!/learn/fundamentals/modules/container) documentation.
320
321 </Table.Cell>
322 <Table.Cell>
323
324 Each service is registered as the camel-cased name of the service. For example:
325
326 - `BrandModuleService` is registered as `brandModuleService`.
327 - `CmsService` is registered as `cmsService`.
328
329 </Table.Cell>
330 </Table.Row>
331 </Table.Body>
332 </Table>