-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unscoped variables support #24
base: master
Are you sure you want to change the base?
Add unscoped variables support #24
Conversation
@@ -326,8 +337,8 @@ Library will throw an error on launch application: `Cat.weight received 'not_a_n | |||
|
|||
## Requirements | |||
|
|||
1. @nestjs/common ^7.2.0 | |||
2. @nestjs/core ^7.2.0 | |||
1. @nestjs/common >=7.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Или "^9.1.4" ?
import { plainToClass } from '../transformer'; | ||
|
||
export class ConfigFactory { | ||
public createConfig( | ||
configStorage: ConfigStorage, | ||
ConfigClass: ClassType, | ||
): typeof ConfigClass.prototype { | ||
if (ConfigClass[UNSCOPED_CONFIG_SYMBOL]) { | ||
return plainToClass(ConfigClass, configStorage[UNSCOPED_CONFIG_SYMBOL], { | ||
excludeExtraneousValues: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there will be different behaviour with @UnscopedConfig
and usuall @Config
. So after migration could be implicit consequences
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, but without excludeExtraneousValues all envs will be automatically exposed to class instance which is more terrible than the inconsistent behavior. Moreover, I do not understand why this option is not enabled in the @Config
mode. And, I hope, @UnscopedConfig
is more for migration cases than for everyday use, because implementation is one big workaround.
I think we should describe excludeExtraneousValues
behavior in readme of @UnscopedConfig
and enable it for @Config
in next major version.
P.S. But in general, you gave me a strange idea how to reduce workaroundness of this solution, I'll try to implement it.
I want add ability to map raw variables without
MODULE__
prefix for simplify migration.In this case config definition will be similar to this:
For details see changes in README and e2e tests.