From 9ba10ef465ee2a2dad69fcc4c329b4af734681d4 Mon Sep 17 00:00:00 2001 From: Vahid Najafi Date: Sat, 26 Jun 2021 15:53:56 +0430 Subject: [PATCH 1/2] docs: add more docs for useClass usage --- README.md | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ea5524d..c7b7afb 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ const rates = { export class AppModule {} ``` -### forRootAsync with configuration +### forRootAsync with configuration and useFactory ```TS @Module({ @@ -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('BASE'), + rates + }; + } +} +``` + ## Convert In order to convert currencies to each other in controllers or services, we have two approaches: From 98541cfec0223ff1e17ffb012fae7b09d04f1f76 Mon Sep 17 00:00:00 2001 From: Vahid Najafi Date: Sat, 26 Jun 2021 15:55:09 +0430 Subject: [PATCH 2/2] chore(release): Release 1.1.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fba060..ae447dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index bcccfa1..65ecd06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nestjs-cashify", - "version": "1.1.0", + "version": "1.1.1", "description": "Currency conversion module for nest", "author": "Vahid Najafi ", "license": "MIT",