Skip to content

Commit

Permalink
docs: Update getting started
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Mar 17, 2022
1 parent a04f7cb commit c75e3b3
Show file tree
Hide file tree
Showing 53 changed files with 218 additions and 451 deletions.
82 changes: 2 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,89 +80,11 @@ Depending on your situation, pick the right getting started section.

In that case, you must already have scaffold a new medusa store project. If that's not the case you can [follow the tutorial here](https://docs.medusajs.com/quickstart/quick-start).

Run the following command in your terminal
Run the following command in your terminal (The last version is 1.5.5)

```bash
npm install medusa-extender
```

To benefit from all the features that the extender offers you, the usage of typescript is recommended.

Then let's create the `tsconfig.json` configuration

```bash
npm i -D typescript
echo '{
"compilerOptions": {
"module": "CommonJS",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"target": "es2017",
"sourceMap": true,
"skipLibCheck": true,
"allowJs": true,
"outDir": "dist",
"rootDir": "src",
"esModuleInterop": true
},
"include": [
"src"
],
"exclude": [
"dist",
"node_modules",
"**/*.spec.ts"
]
}' > tsconfig.json
```

update the scripts in your `package.json`

```json
{
"scripts": {
"build": "rm -rf dist && tsc",
"start": "npm run build && node dist/main.js"
}
}
```

add a main file in the `src` directory

```typescript
// src/main.ts

import express = require('express');
import { Medusa } from 'medusa-extender';
import { resolve } from 'path';

async function bootstrap() {
const expressInstance = express();

const rootDir = resolve(__dirname, '..');
await new Medusa(rootDir, expressInstance).load([]);

expressInstance.listen(9000, () => {
console.info('Server successfully started on port 9000');
});
}

bootstrap();
```

And finally update the `develop.sh` script with the following

```bash
#!/bin/bash

#Run migrations to ensure the database is updated
medusa migrations run

#Start development environment
npm run start
./node_modules/.bin/medex init
```

That's it, you are now ready to run your server :rocket:
Expand Down
91 changes: 12 additions & 79 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
* [Utilities :wrench:](#utilities-wrench)
* [attachOrReplaceEntitySubscriber](#attachorreplaceentitysubscriber)
* [repositoryMixin](#repositorymixin)
* [Omit](#omit)
* [Starters](#starters)
* [Internal modules](#internal-modules)
* [Monitoring](#monitoring)
Expand Down Expand Up @@ -115,85 +116,7 @@ Run the following command in your terminal (The last version is 1.5.5)

```bash
npm install medusa-extender
```

To benefit from all the features that the extender offers you, the usage of typescript is recommended.

Then let's create the `tsconfig.json` configuration

```bash
npm i -D typescript
echo '{
"compilerOptions": {
"module": "CommonJS",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"target": "es2017",
"sourceMap": true,
"skipLibCheck": true,
"allowJs": true,
"outDir": "dist",
"rootDir": "src",
"esModuleInterop": true
},
"include": [
"src"
],
"exclude": [
"dist",
"node_modules",
"**/*.spec.ts"
]
}' > tsconfig.json
```

update the scripts in your `package.json`

```json
{
"scripts": {
"build": "rm -rf dist && tsc",
"start": "npm run build && node dist/main.js"
}
}
```

add a main file in the `src` directory

```typescript
// src/main.ts

import express = require('express');
import { Medusa } from 'medusa-extender';
import { resolve } from 'path';

async function bootstrap() {
const expressInstance = express();

const rootDir = resolve(__dirname, '..');
await new Medusa(rootDir, expressInstance).load([]);

expressInstance.listen(9000, () => {
console.info('Server successfully started on port 9000');
});
}

bootstrap();
```

And finally update the `develop.sh` script with the following

```bash
#!/bin/bash

#Run migrations to ensure the database is updated
medusa migrations run

#Start development environment
npm run start
./node_modules/.bin/medex init
```

That's it, you are now ready to run your server :rocket:
Expand Down Expand Up @@ -969,6 +892,16 @@ To usage is easy and can be seen [here](#onmedusaentityevent).
This utility is mandatory when you extend an existing repository.
Since that to be able to work the repository must extend multiple classes in order to reflect the original repository
and the custom extension that you've made. The usage is easy and can be seen [here](#repository).

### Omit

The `Omit` utility allows you to omit a set of properties from a class.
In some cases, extending a class to change the type of a property makes
typescript complains about the typings. In such cases, omitting the parent
property in order to re-create it with your own type in the child class.

> ATTENTION!! This usage must be done carefully to avoid to break things without
> noticing it.
[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/cloudy.png)](#starters)

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:38](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/Medusa.ts#L38)
[src/Medusa.ts:38](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/Medusa.ts#L38)

## Properties

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

#### Defined in

[src/Medusa.ts:31](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/Medusa.ts#L31)
[src/Medusa.ts:31](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/Medusa.ts#L31)

___

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

#### Defined in

[src/Medusa.ts:32](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/Medusa.ts#L32)
[src/Medusa.ts:32](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/Medusa.ts#L32)

## Methods

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

#### Defined in

[src/Medusa.ts:46](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/Medusa.ts#L46)
[src/Medusa.ts:46](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/Medusa.ts#L46)
12 changes: 6 additions & 6 deletions docs/classes/core_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/core/event-emmiter.ts:21](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/core/event-emmiter.ts#L21)
[src/core/event-emmiter.ts:21](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/core/event-emmiter.ts#L21)

## Properties

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

#### Defined in

[src/core/event-emmiter.ts:19](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/core/event-emmiter.ts#L19)
[src/core/event-emmiter.ts:19](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/core/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/core/event-emmiter.ts:80](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/core/event-emmiter.ts#L80)
[src/core/event-emmiter.ts:80](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/core/event-emmiter.ts#L80)

___

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

#### Defined in

[src/core/event-emmiter.ts:31](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/core/event-emmiter.ts#L31)
[src/core/event-emmiter.ts:31](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/core/event-emmiter.ts#L31)

___

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

#### Defined in

[src/core/event-emmiter.ts:43](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/core/event-emmiter.ts#L43)
[src/core/event-emmiter.ts:43](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/core/event-emmiter.ts#L43)

___

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

#### Defined in

[src/core/event-emmiter.ts:68](https://github.com/adrien2p/medusa-extender/blob/37cc0bb/src/core/event-emmiter.ts#L68)
[src/core/event-emmiter.ts:68](https://github.com/adrien2p/medusa-extender/blob/a04f7cb/src/core/event-emmiter.ts#L68)
Loading

0 comments on commit c75e3b3

Please sign in to comment.