Skip to content

Commit

Permalink
feat: Improve middlewares and routers management when adding to medus…
Browse files Browse the repository at this point in the history
…a core
  • Loading branch information
adrien2p committed Feb 26, 2022
1 parent 575c26f commit db44735
Show file tree
Hide file tree
Showing 56 changed files with 573 additions and 577 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ dist
tsconfig.tsbuildinfo
uploads
coverage
coverage-badges
coverage-badges/
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<a href="https://github.com/adrien2p/medusa-extender/commits/main"><img src="https://img.shields.io/github/commit-activity/m/adrien2p/medusa-extender?style=flat-square" alt="activity" height="18"></a>
<a href="https://github.com/adrien2p/medusa-extender/issues"><img src="https://img.shields.io/github/issues/adrien2p/medusa-extender?style=flat-square" alt="issues" height="18"></a>
<a href="https://www.npmjs.com/package/medusa-extender"><img src="https://img.shields.io/npm/dm/medusa-extender?style=flat-square" alt="download" height="18"></a>
<a href="https://github.com/adrien2p/medusa-extender/blob/assets/assets/coverage/badge-statements.svg?raw=true"><img src="https://github.com/adrien2p/medusa-extender/blob/assets/assets/coverage/badge-statements.svg?raw=true" alt="coverage" height="18"></a>
<a href="https://github.com/adrien2p/medusa-extender/blob/main/LICENSE"><img src="https://img.shields.io/github/license/adrien2p/medusa-extender?style=flat-square" alt="licence" height="18"></a>
<a href="https://twitter.com/intent/tweet?text=Check%20this%20out!%20The%20new%20medusa%20headless%20e-commerce%20extender&url=https://github.com/adrien2p/medusa-extender"><img src="https://badgen.net/badge/icon/twitter?icon=twitter&label=Share%20it%20on" alt="twitter" height="18"></a>
<a href="https://discord.gg/xpCwq3Kfn8">
Expand Down
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ medusa-extender / [Exports](modules.md)
<a href="https://github.com/adrien2p/medusa-extender/commits/main"><img src="https://img.shields.io/github/commit-activity/m/adrien2p/medusa-extender?style=flat-square" alt="activity" height="18"></a>
<a href="https://github.com/adrien2p/medusa-extender/issues"><img src="https://img.shields.io/github/issues/adrien2p/medusa-extender?style=flat-square" alt="issues" height="18"></a>
<a href="https://www.npmjs.com/package/medusa-extender"><img src="https://img.shields.io/npm/dm/medusa-extender?style=flat-square" alt="download" height="18"></a>
<a href="https://github.com/adrien2p/medusa-extender/blob/assets/assets/coverage/badge-statements.svg?raw=true"><img src="https://github.com/adrien2p/medusa-extender/blob/assets/assets/coverage/badge-statements.svg?raw=true" alt="coverage" height="18"></a>
<a href="https://github.com/adrien2p/medusa-extender/blob/main/LICENSE"><img src="https://img.shields.io/github/license/adrien2p/medusa-extender?style=flat-square" alt="licence" height="18"></a>
<a href="https://twitter.com/intent/tweet?text=Check%20this%20out!%20The%20new%20medusa%20headless%20e-commerce%20extender&url=https://github.com/adrien2p/medusa-extender"><img src="https://badgen.net/badge/icon/twitter?icon=twitter&label=Share%20it%20on" alt="twitter" height="18"></a>
<a href="https://discord.gg/xpCwq3Kfn8">
Expand Down
10 changes: 5 additions & 5 deletions docs/classes/Medusa.Medusa-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Load medusa and apply all components

#### Defined in

[src/Medusa.ts:38](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/Medusa.ts#L38)
[src/Medusa.ts:37](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/Medusa.ts#L37)

## Properties

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

#### Defined in

[src/Medusa.ts:31](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/Medusa.ts#L31)
[src/Medusa.ts:30](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/Medusa.ts#L30)

___

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

#### Defined in

[src/Medusa.ts:32](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/Medusa.ts#L32)
[src/Medusa.ts:31](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/Medusa.ts#L31)

## Methods

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

#### Defined in

[src/Medusa.ts:46](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/Medusa.ts#L46)
[src/Medusa.ts:45](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/Medusa.ts#L45)

___

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

#### Defined in

[src/Medusa.ts:76](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/Medusa.ts#L76)
[src/Medusa.ts:82](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/Medusa.ts#L82)
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:42](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L42)
[src/decorators/onMedusaEntityEvent.decorator.ts:42](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L42)

## Properties

Expand All @@ -55,7 +55,7 @@

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:40](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L40)
[src/decorators/onMedusaEntityEvent.decorator.ts:40](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L40)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:39](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L39)
[src/decorators/onMedusaEntityEvent.decorator.ts:39](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L39)

## Accessors

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:50](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L50)
[src/decorators/onMedusaEntityEvent.decorator.ts:50](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L50)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:46](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L46)
[src/decorators/onMedusaEntityEvent.decorator.ts:46](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L46)

## Methods

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:70](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L70)
[src/decorators/onMedusaEntityEvent.decorator.ts:70](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L70)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:58](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L58)
[src/decorators/onMedusaEntityEvent.decorator.ts:58](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L58)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:84](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L84)
[src/decorators/onMedusaEntityEvent.decorator.ts:84](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L84)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:66](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L66)
[src/decorators/onMedusaEntityEvent.decorator.ts:66](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L66)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:77](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L77)
[src/decorators/onMedusaEntityEvent.decorator.ts:77](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L77)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:62](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L62)
[src/decorators/onMedusaEntityEvent.decorator.ts:62](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L62)

___

Expand Down Expand Up @@ -280,7 +280,7 @@ ___

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:91](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L91)
[src/decorators/onMedusaEntityEvent.decorator.ts:91](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L91)

___

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

#### Defined in

[src/decorators/onMedusaEntityEvent.decorator.ts:54](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/decorators/onMedusaEntityEvent.decorator.ts#L54)
[src/decorators/onMedusaEntityEvent.decorator.ts:54](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/decorators/onMedusaEntityEvent.decorator.ts#L54)
12 changes: 6 additions & 6 deletions docs/classes/event_emmiter.Internals.CustomEventEmmiter.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EventEmitter.constructor

#### Defined in

[src/event-emmiter.ts:21](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/event-emmiter.ts#L21)
[src/event-emmiter.ts:21](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/event-emmiter.ts#L21)

## Properties

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

#### Defined in

[src/event-emmiter.ts:19](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/event-emmiter.ts#L19)
[src/event-emmiter.ts:19](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/event-emmiter.ts#L19)

## Methods

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

#### Defined in

[src/event-emmiter.ts:80](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/event-emmiter.ts#L80)
[src/event-emmiter.ts:80](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/event-emmiter.ts#L80)

___

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

#### Defined in

[src/event-emmiter.ts:31](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/event-emmiter.ts#L31)
[src/event-emmiter.ts:31](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/event-emmiter.ts#L31)

___

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

#### Defined in

[src/event-emmiter.ts:43](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/event-emmiter.ts#L43)
[src/event-emmiter.ts:43](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/event-emmiter.ts#L43)

___

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

#### Defined in

[src/event-emmiter.ts:68](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/event-emmiter.ts#L68)
[src/event-emmiter.ts:68](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/event-emmiter.ts#L68)
2 changes: 1 addition & 1 deletion docs/classes/metadata_reader.Internals.CustomMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ Map.get

#### Defined in

[src/metadata-reader.ts:5](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/metadata-reader.ts#L5)
[src/metadata-reader.ts:5](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/metadata-reader.ts#L5)
87 changes: 39 additions & 48 deletions docs/classes/utils.Utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,34 @@ Utilities helper methods.

- [constructor](utils.Utils.md#constructor)

### Properties

- [logs](utils.Utils.md#logs)

### Methods

- [attachOrReplaceEntitySubscriber](utils.Utils.md#attachorreplaceentitysubscriber)
- [log](utils.Utils.md#log)
- [logRoutes](utils.Utils.md#logroutes)
- [printRoutes](utils.Utils.md#printroutes)
- [displayLogs](utils.Utils.md#displaylogs)
- [hydrateLog](utils.Utils.md#hydratelog)
- [hydrateRouteLog](utils.Utils.md#hydrateroutelog)
- [repositoryMixin](utils.Utils.md#repositorymixin)
- [splitRoutes](utils.Utils.md#splitroutes)

## Constructors

### constructor

**new Utils**()

## Properties

### logs

`Static` **logs**: `string`[][] = `[]`

#### Defined in

[src/utils.ts:13](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/utils.ts#L13)

## Methods

### attachOrReplaceEntitySubscriber
Expand Down Expand Up @@ -56,74 +69,72 @@ Attach a new subscriber to a specific entities.

#### Defined in

[src/utils.ts:37](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/utils.ts#L37)
[src/utils.ts:40](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/utils.ts#L40)

___

### log

`Static` **log**(`context`, `description`, ...`variables`): `void`

Prepare the log to be shown to be consistent everywhere.
### displayLogs

#### Parameters
`Static` **displayLogs**(): `void`

| Name | Type | Description |
| :------ | :------ | :------ |
| `context` | `string` | Where the log comes from |
| `description` | `string` | The description of the action logged |
| `...variables` | `string`[] | The variable that populate the logs |
**`internal`**
Display the logs that has been registered during the build time.

#### Returns

`void`

#### Defined in

[src/utils.ts:68](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/utils.ts#L68)
[src/utils.ts:90](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/utils.ts#L90)

___

### logRoutes
### hydrateLog

`Static` **logRoutes**(`express`): `void`
`Static` **hydrateLog**(`context`, `description`, ...`variables`): `void`

Log all the routes from the express instance.
**`internal`**
Prepare the log to be shown to be consistent everywhere.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `express` | `Express` | Express instance |
| `context` | `string` | Where the log comes from |
| `description` | `string` | The description of the action logged |
| `...variables` | `string`[] | The variable that populate the logs |

#### Returns

`void`

#### Defined in

[src/utils.ts:58](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/utils.ts#L58)
[src/utils.ts:64](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/utils.ts#L64)

___

### printRoutes
### hydrateRouteLog

`Static` `Private` **printRoutes**(`path`, `layer`): `void`
`Static` **hydrateRouteLog**(`app`): `void`

**`internal`**
Prepare the logs the show all available routes on the app.

#### Parameters

| Name | Type |
| :------ | :------ |
| `path` | `string`[] |
| `layer` | `any` |
| `app` | `Express` |

#### Returns

`void`

#### Defined in

[src/utils.ts:82](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/utils.ts#L82)
[src/utils.ts:77](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/utils.ts#L77)

___

Expand Down Expand Up @@ -153,24 +164,4 @@ Since it is not possible to use multiple extend, you can use that utilities to a

#### Defined in

[src/utils.ts:17](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/utils.ts#L17)

___

### splitRoutes

`Static` `Private` **splitRoutes**(`thing`): `string` \| `string`[]

#### Parameters

| Name | Type |
| :------ | :------ |
| `thing` | `string` \| `RegExp` & { `fast_slash`: `boolean` } |

#### Returns

`string` \| `string`[]

#### Defined in

[src/utils.ts:102](https://github.com/adrien2p/medusa-extender/blob/c2d2cfc/src/utils.ts#L102)
[src/utils.ts:20](https://github.com/adrien2p/medusa-extender/blob/575c26f/src/utils.ts#L20)
Loading

0 comments on commit db44735

Please sign in to comment.