docs: fix options details passed to endpoints (#4579)

* docs: fix options details passed to endpoints

* added access configuration sections

* added section about parsing request body
This commit is contained in:
Shahed Nasser
2023-07-21 12:42:21 +03:00
committed by GitHub
parent d766f74c14
commit e1e7d8e5e4
3 changed files with 181 additions and 3 deletions

View File

@@ -54,6 +54,39 @@ eventBusService.subscribe("order.placed", this.handleOrder, {
---
## Retrieve Medusa Configurations
Within your subscriber, you may need to access the Medusa configuration exported from `medusa-config.js`. To do that, you can access `configModule` using dependency injection.
For example:
```ts
import { ConfigModule, EventBusService } from "@medusajs/medusa"
type InjectedDependencies = {
eventBusService: EventBusService
configModule: ConfigModule
}
class OrderNotifierSubscriber {
protected readonly configModule_: ConfigModule
constructor({
eventBusService,
configModule,
}: InjectedDependencies) {
this.configModule_ = configModule
eventBusService.subscribe("order.placed", this.handleOrder)
}
// ...
}
export default OrderNotifierSubscriber
```
---
## Using Services in Subscribers
You can access any service through the dependencies injected to your subscribers constructor.