Skip to content

Commit

Permalink
Merge branch 'feature/docs-v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidvdn committed Jun 26, 2021
2 parents e811bf5 + 98541cf commit ff59f89
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## RELEASE 1.1.1
### Feature
* Add more docs for useClass

## RELEASE 1.1.0
### Feature
* Add full support for useClass and useExisting
Expand Down
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const rates = {
export class AppModule {}
```

### forRootAsync with configuration
### forRootAsync with configuration and useFactory

```TS
@Module({
Expand All @@ -54,6 +54,43 @@ export class AppModule {}
export class AppModule {}
```

### forRootAsync with configuration and useClass

```TS
@Module({
imports: [
CashifyModule.forRootAsync({
useClass: CashifyConfigService,
import: [ConfigModule],
extraProviders: [ConfigService],
})
]
})
export class AppModule {}
```
And for `CashifyConfigService` we have the following:

```TS
import { CashifyOptionsFactory } from 'nestjs-cashify';

@Injectable()
export class CashifyConfigService implements CashifyOptionsFactory {
constructor(private configService: ConfigService) {}

createCashifyOptions() {
const rates = {
GBP: 0.92,
EUR: 1.00,
USD: 1.12
};
return {
base: this.configService.get<string>('BASE'),
rates
};
}
}
```

## Convert

In order to convert currencies to each other in controllers or services, we have two approaches:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nestjs-cashify",
"version": "1.1.0",
"version": "1.1.1",
"description": "Currency conversion module for nest",
"author": "Vahid Najafi <vahid.vdn@gmail.com>",
"license": "MIT",
Expand Down

0 comments on commit ff59f89

Please sign in to comment.