Skip to content
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

feat(core): direct subtemplates access #19

Merged
merged 4 commits into from
Feb 11, 2024
Merged

Conversation

Matii96
Copy link
Owner

@Matii96 Matii96 commented Jan 29, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What is the current behavior?

Nested configs can only be accessed via parents.

What is the new behavior?

Nested configs can accessed directly.

class DbConfig {
  @IsString()
  url: string;
}

class AppConfig {
  @IsInt()
  port: number;

  @Nested(() => DbConfig)
  db: DbConfig;
}

Config.registerSync({
  template: AppConfig,
  adapter: () => ({ port: 3000, db: { url: 'db://localhost:5467' } }),
});

console.log('Db url: ' + Config.getValues(DbConfig).url) // => Db url: db://localhost:5467

Subtemplates can be accessed directly without a need to pass through parents
@Matii96 Matii96 added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 29, 2024
@Matii96 Matii96 self-assigned this Jan 29, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (189c944) 97.60% compared to head (ef56c1b) 97.03%.
Report is 1 commits behind head on main.

Files Patch % Lines
...core/lib/manager/source-group/source-group.impl.ts 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
- Coverage   97.60%   97.03%   -0.57%     
==========================================
  Files          34       36       +2     
  Lines         376      405      +29     
  Branches       69       72       +3     
==========================================
+ Hits          367      393      +26     
- Misses          9       12       +3     
Flag Coverage Δ
unittests 97.03% <98.00%> (-0.57%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Matii96 Matii96 mentioned this pull request Jan 29, 2024
2 tasks
@Matii96 Matii96 merged commit fdca8de into main Feb 11, 2024
11 checks passed
@Matii96 Matii96 deleted the direct-subtemplates-access branch February 11, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants