From b50725435f0d4c93bfcb91adb6c5b942d702688f Mon Sep 17 00:00:00 2001 From: nikaple Date: Mon, 17 May 2021 12:30:37 +0800 Subject: [PATCH] chore: update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bacece36..9c4fcebe 100644 --- a/README.md +++ b/README.md @@ -407,9 +407,9 @@ export class Config { } ``` -## Using config in decorators +## Using config outside Nest's IoC container (Usage in decorators) -> **CAUTION!** You can't use config in decorators through dependency injection, using it will make you struggle harder writing unit tests. +> **CAUTION!** Using config outside Nest's IoC container will make you struggle harder writing unit tests, you should avoid this pattern as much as possible. Due to the nature of JavaScript loading modules, decorators are executed before Nest's module initialization. If you want to get config value in decorators like `@Controller()` or `@WebSocketGateway()`, config module should be initialized before application bootstrap.