Skip to content

Commit

Permalink
docs: update API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Aug 14, 2022
1 parent f27eb84 commit 7e1bb9b
Show file tree
Hide file tree
Showing 60 changed files with 214 additions and 181 deletions.
33 changes: 28 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ export default class MyCustomService {

private readonly manager: EntityManager;

constructor(private readonly container: ConstructorParams) {
this.manager = container.manager;
constructor({ manager }: ConstructorParams) {
this.manager = manager;
}
}
```
Expand Down Expand Up @@ -577,7 +577,7 @@ export default class MyCustomService {
private readonly manager: EntityManager;

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

Expand Down Expand Up @@ -940,7 +940,26 @@ export default class ProductSubscriber implements EntitySubscriberInterface<Prod
}
```

Here is how you can register it in medusa
Here is how you can register it in medusa.

```typescript
import ProductSubscriber from './product.subscriber';

@Service({ override: MedusaProductService, scope: 'SCOPED' })
export default class ProductService extends MedusaProductService {
private readonly manager: EntityManager;

constructor({ manager }: ConstructorParams) {
super({ manager });
this.manager = manager;
ProductSubscriber.attachTo(manager.connection)
}
}
```

Here is how you can register it in medusa if your subscriber need to be scoped
- for example if the manager can be scoped like it is in a multi tenant application such as the one using the multi tenancy module).
- if the service depends on scoped dependencies such as the logged in user.

```typescript
import { NextFunction, Response } from 'express';
Expand Down Expand Up @@ -968,13 +987,17 @@ export class AttachProductSubscribersMiddleware implements MedusaMiddleware {
And finally, we will add a new handler to listen to this particular event

```typescript
import ProductSubscriber from './product.subscriber';

@Service({ override: MedusaProductService, scope: 'SCOPED' })
export default class ProductService extends MedusaProductService {
private readonly manager: EntityManager;

constructor(private readonly container: ConstructorParams) {
constructor(container: ConstructorParams) {
super(container);
this.manager = container.manager;
// You don't need to register it again if it is registered through a middleware.
ProductSubscriber.attachTo(this.manager.connection)
}

/* ... */
Expand Down
8 changes: 4 additions & 4 deletions docs/classes/Medusa.Medusa-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Load medusa and apply all components

#### Defined in

[src/Medusa.ts:39](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/Medusa.ts#L39)
[src/Medusa.ts:39](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/Medusa.ts#L39)

## Properties

Expand All @@ -46,7 +46,7 @@ Load medusa and apply all components

#### Defined in

[src/Medusa.ts:32](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/Medusa.ts#L32)
[src/Medusa.ts:32](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/Medusa.ts#L32)

___

Expand All @@ -56,7 +56,7 @@ ___

#### Defined in

[src/Medusa.ts:33](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/Medusa.ts#L33)
[src/Medusa.ts:33](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/Medusa.ts#L33)

## Methods

Expand All @@ -76,4 +76,4 @@ ___

#### Defined in

[src/Medusa.ts:47](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/Medusa.ts#L47)
[src/Medusa.ts:47](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/Medusa.ts#L47)
2 changes: 1 addition & 1 deletion docs/classes/core_componentMap.ComponentMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ Map.get

#### Defined in

[src/core/componentMap.ts:4](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/componentMap.ts#L4)
[src/core/componentMap.ts:4](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/componentMap.ts#L4)
26 changes: 6 additions & 20 deletions docs/classes/core_event_emmiter.Internals.CustomEventEmmiter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Extended event emitter to register methods that must be call when certain events
- [emitAsync](core_event_emmiter.Internals.CustomEventEmmiter.md#emitasync)
- [register](core_event_emmiter.Internals.CustomEventEmmiter.md#register)
- [registerListeners](core_event_emmiter.Internals.CustomEventEmmiter.md#registerlisteners)
- [unregisterListeners](core_event_emmiter.Internals.CustomEventEmmiter.md#unregisterlisteners)

## Constructors

Expand All @@ -41,7 +40,7 @@ EventEmitter.constructor

#### Defined in

[src/core/event-emmiter.ts:22](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/event-emmiter.ts#L22)
[src/core/event-emmiter.ts:22](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/event-emmiter.ts#L22)

## Properties

Expand All @@ -51,7 +50,7 @@ EventEmitter.constructor

#### Defined in

[src/core/event-emmiter.ts:20](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/event-emmiter.ts#L20)
[src/core/event-emmiter.ts:20](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/event-emmiter.ts#L20)

## Methods

Expand Down Expand Up @@ -80,7 +79,7 @@ Emit an asynchrone event entity based and wait for the result.

#### Defined in

[src/core/event-emmiter.ts:79](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/event-emmiter.ts#L79)
[src/core/event-emmiter.ts:74](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/event-emmiter.ts#L74)

___

Expand Down Expand Up @@ -110,7 +109,7 @@ Register a new event handler.

#### Defined in

[src/core/event-emmiter.ts:32](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/event-emmiter.ts#L32)
[src/core/event-emmiter.ts:32](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/event-emmiter.ts#L32)

___

Expand All @@ -119,6 +118,7 @@ ___
**registerListeners**(`container`): `void`

Apply all event handlers hold by the `listenerDescriptor`.
Only unregister and register again non singleton based event listeners

#### Parameters

Expand All @@ -132,18 +132,4 @@ Apply all event handlers hold by the `listenerDescriptor`.

#### Defined in

[src/core/event-emmiter.ts:44](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/event-emmiter.ts#L44)

___

### unregisterListeners

**unregisterListeners**(): `void`

#### Returns

`void`

#### Defined in

[src/core/event-emmiter.ts:67](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/event-emmiter.ts#L67)
[src/core/event-emmiter.ts:45](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/event-emmiter.ts#L45)
26 changes: 13 additions & 13 deletions docs/classes/core_logger.Logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Internal logger to display information about the build.

#### Defined in

[src/core/logger.ts:20](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L20)
[src/core/logger.ts:20](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L20)

## Properties

Expand All @@ -59,7 +59,7 @@ Internal logger to display information about the build.

#### Defined in

[src/core/logger.ts:10](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L10)
[src/core/logger.ts:10](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L10)

___

Expand All @@ -69,7 +69,7 @@ ___

#### Defined in

[src/core/logger.ts:9](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L9)
[src/core/logger.ts:9](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L9)

___

Expand All @@ -79,7 +79,7 @@ ___

#### Defined in

[src/core/logger.ts:8](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L8)
[src/core/logger.ts:8](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L8)

## Accessors

Expand All @@ -93,7 +93,7 @@ ___

#### Defined in

[src/core/logger.ts:16](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L16)
[src/core/logger.ts:16](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L16)

___

Expand All @@ -107,7 +107,7 @@ ___

#### Defined in

[src/core/logger.ts:12](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L12)
[src/core/logger.ts:12](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L12)

## Methods

Expand All @@ -131,7 +131,7 @@ Build logs taking in count the level color

#### Defined in

[src/core/logger.ts:89](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L89)
[src/core/logger.ts:89](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L89)

___

Expand All @@ -154,7 +154,7 @@ Display error logs in red immediately

#### Defined in

[src/core/logger.ts:66](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L66)
[src/core/logger.ts:66](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L66)

___

Expand All @@ -170,7 +170,7 @@ display all queues logs and then reset the queue.

#### Defined in

[src/core/logger.ts:73](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L73)
[src/core/logger.ts:73](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L73)

___

Expand All @@ -193,7 +193,7 @@ Display log immediately.

#### Defined in

[src/core/logger.ts:48](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L48)
[src/core/logger.ts:48](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L48)

___

Expand All @@ -216,7 +216,7 @@ Push new logs to queue and then show them later on.

#### Defined in

[src/core/logger.ts:34](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L34)
[src/core/logger.ts:34](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L34)

___

Expand All @@ -239,7 +239,7 @@ Display warning immediately.

#### Defined in

[src/core/logger.ts:57](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L57)
[src/core/logger.ts:57](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L57)

___

Expand All @@ -260,4 +260,4 @@ ___

#### Defined in

[src/core/logger.ts:25](https://github.com/adrien2p/medusa-extender/blob/19c4679/src/core/logger.ts#L25)
[src/core/logger.ts:25](https://github.com/adrien2p/medusa-extender/blob/f27eb84/src/core/logger.ts#L25)
Loading

0 comments on commit 7e1bb9b

Please sign in to comment.