docs: fix code block titles (#5733)

* docs: fix code block titles

* remove console

* fix build error
This commit is contained in:
Shahed Nasser
2023-11-27 16:08:10 +00:00
committed by GitHub
parent de8f748674
commit 547b16ead5
110 changed files with 483 additions and 456 deletions
@@ -29,7 +29,7 @@ Create the file `services/event-bus-custom.ts` which will hold your event bus se
Add the following content to the file:
```ts title=services/event-bus-custom.ts
```ts title="services/event-bus-custom.ts"
import { EmitData, EventBusTypes } from "@medusajs/types"
import { AbstractEventBusModuleService } from "@medusajs/utils"
@@ -81,7 +81,7 @@ Heres an example of how you can use the `constructor` to store the options of
<!-- eslint-disable prefer-rest-params -->
```ts title=services/event-bus-custom.ts
```ts title="services/event-bus-custom.ts"
class CustomEventBus extends AbstractEventBusModuleService {
protected readonly moduleOptions: Record<string, any>
@@ -109,7 +109,7 @@ The `emit` method has two different signatures:
The `options` parameter depends on the event bus integration. For example, the Redis event bus accepts the following options:
```ts title=services/event-bus-custom.ts
```ts title="services/event-bus-custom.ts"
type JobData<T> = {
eventName: string
data: T
@@ -119,7 +119,7 @@ type JobData<T> = {
You can implement your method in a way that supports both signatures by checking the type of the first input. For example:
```ts title=services/event-bus-custom.ts
```ts title="services/event-bus-custom.ts"
class CustomEventBus extends AbstractEventBusModuleService {
// ...
async emit<T>(
@@ -154,7 +154,7 @@ The `subscribe` method accepts three parameters:
The implementation of this method depends on the service youre using for the event bus:
```ts title=services/event-bus-custom.ts
```ts title="services/event-bus-custom.ts"
class CustomEventBus extends AbstractEventBusModuleService {
// ...
subscribe(
@@ -180,7 +180,7 @@ The `unsubscribe` method accepts three parameters:
The implementation of this method depends on the service youre using for the event bus:
```ts title=services/event-bus-custom.ts
```ts title="services/event-bus-custom.ts"
class CustomEventBus extends AbstractEventBusModuleService {
// ...
unsubscribe(
@@ -200,7 +200,7 @@ After implementing the event bus service, you must export it so that the Medusa
Create the file `index.ts` with the following content:
```ts title=services/event-bus-custom.ts
```ts title="services/event-bus-custom.ts"
import { ModuleExports } from "@medusajs/modules-sdk"
import { CustomEventBus } from "./services"
@@ -226,7 +226,7 @@ You can test your module in the Medusa backend by referencing it in the configur
To do that, add the module to the exported configuration in `medusa-config.js` as follows:
```js title=medusa-config.js
```js title="medusa-config.js"
module.exports = {
// ...
modules: {
@@ -23,7 +23,7 @@ The `eventBusService.subscribe` method receives the name of the event as a first
For example, here is the `OrderNotifierSubscriber` class created in `src/subscribers/order-notifier.ts`:
```ts title=src/subscribers/order-notifier.ts
```ts title="src/subscribers/order-notifier.ts"
class OrderNotifierSubscriber {
constructor({ eventBusService }) {
eventBusService.subscribe("order.placed", this.handleOrder)
@@ -99,7 +99,7 @@ You can access any service through the dependencies injected to your subscriber
For example:
```ts title=src/subscribers/order-notifier.ts
```ts title="src/subscribers/order-notifier.ts"
class OrderNotifierSubscriber {
constructor({ productService, eventBusService }) {
this.productService = productService
@@ -115,7 +115,7 @@ class OrderNotifierSubscriber {
You can then use `this.productService` anywhere in your subscribers methods. For example:
```ts title=src/subscribers/order-notifier.ts
```ts title="src/subscribers/order-notifier.ts"
class OrderNotifierSubscriber {
// ...
handleOrder = async (data) => {
@@ -21,7 +21,7 @@ The subscriber file exports a default handler function, and the subscriber's con
For example:
```ts title=src/subscribers/product-update-handler.ts
```ts title="src/subscribers/product-update-handler.ts"
import {
ProductService,
type SubscriberConfig,
@@ -107,7 +107,7 @@ Within your subscriber, you may need to access the Medusa configuration exported
For example:
```ts title=src/subscribers/product-update-handler.ts
```ts title="src/subscribers/product-update-handler.ts"
import {
ProductService,
type SubscriberConfig,
@@ -37,7 +37,7 @@ npm install @medusajs/event-bus-local
In `medusa-config.js`, add the following to the exported object:
```js title=medusa-config.js
```js title="medusa-config.js"
module.exports = {
// ...
modules: {
@@ -55,7 +55,7 @@ Where `<YOUR_REDIS_URL>` is a connection URL to your Redis instance.
In `medusa-config.js`, add the following to the exported object:
```js title=medusa-config.js
```js title="medusa-config.js"
module.exports = {
// ...
modules: {