Skip to content

Commit

Permalink
feat(config): add optional generic type to config service
Browse files Browse the repository at this point in the history
  • Loading branch information
yharaskrik committed May 19, 2020
1 parent 7da741d commit 83a014c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { NoInferType } from './types';

@Injectable()
export class ConfigService {
export class ConfigService<K = any> {
constructor(
@Optional()
@Inject(CONFIGURATION_TOKEN)
Expand All @@ -22,23 +22,23 @@ export class ConfigService {
* @param propertyPath
* @param defaultValue
*/
get<T = any>(propertyPath: string): T | undefined;
get<T = any>(propertyPath: keyof K): T | undefined;
/**
* Get a configuration value (either custom configuration or process environment variable)
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
* It returns a default value if the key does not exist.
* @param propertyPath
* @param defaultValue
*/
get<T = any>(propertyPath: string, defaultValue: NoInferType<T>): T;
get<T = any>(propertyPath: keyof K, defaultValue: NoInferType<T>): T;
/**
* Get a configuration value (either custom configuration or process environment variable)
* based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
* It returns a default value if the key does not exist.
* @param propertyPath
* @param defaultValue
*/
get<T = any>(propertyPath: string, defaultValue?: T): T | undefined {
get<T = any>(propertyPath: keyof K, defaultValue?: T): T | undefined {
const validatedEnvValue = get(
this.internalConfig[VALIDATED_ENV_PROPNAME],
propertyPath,
Expand Down

0 comments on commit 83a014c

Please sign in to comment.