From 1366f38dbba7be1b27c0a1454a249297169e9e04 Mon Sep 17 00:00:00 2001 From: EeeasyCode Date: Sat, 8 Jun 2024 04:04:19 +0900 Subject: [PATCH 1/7] docs: translate README.md into Korean --- README-ko_kr.md | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 README-ko_kr.md diff --git a/README-ko_kr.md b/README-ko_kr.md new file mode 100644 index 0000000..b51ce1b --- /dev/null +++ b/README-ko_kr.md @@ -0,0 +1,137 @@ + +
+
+ + Logo + + +

@toss/nestjs-aop · npm version

+ +

+ NestJS에 우아하게 AOP를 적용하는 방법 +
+ NestJS 관리 인스턴스를 모든 데코레이터에서 우아하게 사용하세요 + +

+
+ +
+ + +
+ Table of Contents +
    +
  1. Installation
  2. +
  3. Usage
  4. +
  5. References
  6. +
  7. Contributing
  8. +
  9. License
  10. +
+
+ + + + + +## 설치 방법 + +```sh +npm install @toss/nestjs-aop +pnpm add @toss/nestjs-aop +yarn add @toss/nestjs-aop +``` + + + +## 사용 예시 + +#### 1. AopModule Import 하기 +```typescript +@Module({ + imports: [ + // ... + AopModule, + ], +}) +export class AppModule {} +``` + +#### 2. LazyDecorator를 위한 심볼 생성 +```typescript +export const CACHE_DECORATOR = Symbol('CACHE_DECORATOR'); +``` + +#### 3. NestJS 프로바이더를 사용하여 LazyDecorator 구현하기 +`metadata`는 createDecorator의 두 번째 매개변수입니다. + +```typescript +@Aspect(CACHE_DECORATOR) +export class CacheDecorator implements LazyDecorator { + constructor(private readonly cache: Cache) {} + + wrap({ method, metadata: options }: WrapParams) { + return (...args: any) => { + let cachedValue = this.cache.get(...args); + if (!cachedValue) { + cachedValue = method(...args); + this.cache.set(cachedValue, ...args); + } + return cachedValue; + }; + } +} +``` + +#### 4. 모듈의 프로바이더에 LazyDecoratorImpl 추가하기 +```typescript +@Module({ + providers: [CacheDecorator], +}) +export class CacheModule {} +``` + +#### 5. LazyDecorator의 metadata를 나타내는 데코레이터 생성 +`options`는 wrap 메소드에서 얻을 수 있으며 사용될 수 있습니다. + +```typescript +export const Cache = (options: CacheOptions) => createDecorator(CACHE_DECORATOR, options) +``` + +#### 6. 사용하기! +```typescript +export class SomeService { + @Cache({ + // ...options(metadata value) + }) + some() { + // ... + } +} +``` + + + +## 참고자료 +- https://toss.tech/article/nestjs-custom-decorator +- https://youtu.be/VH1GTGIMHQw?t=2973 + + + + +## 기여하기 +이 프로젝트에는 모든 분들의 기여를 환영합니다. 자세한 기여 가이드는 [CONTRIBUTING.md](CONTRIBUTING.md)를 참고하세요. + + + + +## License +MIT © Viva Republica, Inc. [LICENSE](LICENSE) 파일을 참고하세요. + + + + + + + Toss + + From 4aae348e8e6591fb11ba55cc21fce290e8437274 Mon Sep 17 00:00:00 2001 From: EeeasyCode Date: Sat, 8 Jun 2024 04:04:49 +0900 Subject: [PATCH 2/7] docs: translate README.md into Korean --- README-ko_kr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-ko_kr.md b/README-ko_kr.md index b51ce1b..4af1d1e 100644 --- a/README-ko_kr.md +++ b/README-ko_kr.md @@ -61,7 +61,7 @@ export class AppModule {} export const CACHE_DECORATOR = Symbol('CACHE_DECORATOR'); ``` -#### 3. NestJS 프로바이더를 사용하여 LazyDecorator 구현하기 +#### 3. NestJS 프로바이더로 LazyDecorator 구현하기 `metadata`는 createDecorator의 두 번째 매개변수입니다. ```typescript From 406570fba14434103211522a68cdf7311b082e6c Mon Sep 17 00:00:00 2001 From: EeeasyCode Date: Sat, 8 Jun 2024 04:10:21 +0900 Subject: [PATCH 3/7] docs: README.md link to README-ko_kr.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 31b21f3..d9e1b1d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@
+English | [한국어](https://github.com/toss/nestjs-aop/blob/v2.x/README-ko_kr.md) +
Table of Contents @@ -31,7 +33,6 @@ - ## Installation From 950311f1c5deaea9c081325c7c15f3aadf3b5eac Mon Sep 17 00:00:00 2001 From: EeeasyCode Date: Sat, 8 Jun 2024 04:12:14 +0900 Subject: [PATCH 4/7] docs: translate README.md toc into Korean --- README-ko_kr.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README-ko_kr.md b/README-ko_kr.md index 4af1d1e..2120f1c 100644 --- a/README-ko_kr.md +++ b/README-ko_kr.md @@ -17,14 +17,14 @@
- +
- Table of Contents + 목차
    -
  1. Installation
  2. -
  3. Usage
  4. -
  5. References
  6. -
  7. Contributing
  8. +
  9. 설치 방법
  10. +
  11. 사용 예시
  12. +
  13. 참고자료
  14. +
  15. 기여하기
  16. License
From b074892c0481dfbdfdb27b5c2f76c954b1e9cb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Khan=20/=20=EC=9D=B4=EC=B0=BD=EB=AF=BC?= Date: Mon, 10 Jun 2024 17:52:40 +0900 Subject: [PATCH 5/7] docs: change directory name --- README-ko_kr.md => readme_kr.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README-ko_kr.md => readme_kr.md (100%) diff --git a/README-ko_kr.md b/readme_kr.md similarity index 100% rename from README-ko_kr.md rename to readme_kr.md From 469d9cfe1dbeaef0c4e27822f166bcbc1891b722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Khan=20/=20=EC=9D=B4=EC=B0=BD=EB=AF=BC?= Date: Mon, 10 Jun 2024 17:53:59 +0900 Subject: [PATCH 6/7] docs: Translate license name --- readme_kr.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme_kr.md b/readme_kr.md index 2120f1c..84caa16 100644 --- a/readme_kr.md +++ b/readme_kr.md @@ -25,7 +25,7 @@
  • 사용 예시
  • 참고자료
  • 기여하기
  • -
  • License
  • +
  • 라이센스
  • @@ -123,8 +123,8 @@ export class SomeService { - -## License + +## 라이센스 MIT © Viva Republica, Inc. [LICENSE](LICENSE) 파일을 참고하세요. From 0f426cd254d27738f9e22d2d450341b41f8287dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Khan=20/=20=EC=9D=B4=EC=B0=BD=EB=AF=BC?= Date: Mon, 10 Jun 2024 18:12:26 +0900 Subject: [PATCH 7/7] docs: docs: README.md link to readme_kr.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d9e1b1d..f683c0a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@
    -English | [한국어](https://github.com/toss/nestjs-aop/blob/v2.x/README-ko_kr.md) +English | [한국어](https://github.com/toss/nestjs-aop/blob/v2.x/readme_kr.md)