From 3f252fe1d42a6e6437b3bad6b2f0e0a3396d5e42 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 21:23:09 +0900 Subject: [PATCH] docs: translate README.md into Korean (#35) * docs: translate README.md into Korean * docs: translate README.md into Korean * docs: README.md link to README-ko_kr.md * docs: translate README.md toc into Korean * docs: change directory name * docs: Translate license name * docs: docs: README.md link to readme_kr.md --- README.md | 3 +- readme_kr.md | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 readme_kr.md diff --git a/README.md b/README.md index 31b21f3..f683c0a 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@
+English | [한국어](https://github.com/toss/nestjs-aop/blob/v2.x/readme_kr.md) +
Table of Contents @@ -31,7 +33,6 @@ - ## Installation diff --git a/readme_kr.md b/readme_kr.md new file mode 100644 index 0000000..84caa16 --- /dev/null +++ b/readme_kr.md @@ -0,0 +1,137 @@ + +
+
+ + Logo + + +

@toss/nestjs-aop · npm version

+ +

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

+
+ +
+ + +
+ 목차 +
    +
  1. 설치 방법
  2. +
  3. 사용 예시
  4. +
  5. 참고자료
  6. +
  7. 기여하기
  8. +
  9. 라이센스
  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)를 참고하세요. + + + + +## 라이센스 +MIT © Viva Republica, Inc. [LICENSE](LICENSE) 파일을 참고하세요. + + + + + + + Toss + +