1.0.0-beta.33 • Published 5 months ago

@vegajs/config v1.0.0-beta.33

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@vegajs/config

Description

ConfigService is a class that manages the application configuration. It allows you to initialize the configuration, set its values, and access individual configuration parameters.

General Usage

To create an instance of ConfigService, you can pass a default configuration object. Then, using the init method, you can initialize the configuration.

type InitialConfig = {
  apiUrl: string;
}

const configService = new ConfigService<InitialConfig>();

configService.init({ apiUrl: 'https://new-api.example.com' });

Constructor

constructor(defaultConfig?: Config)

  • defaultConfig (optional): a configuration object that will be set as the default when creating an instance.

Methods

init(config: Config): void

Initializes the configuration with a new object.

  • config: the configuration object.

get config(): Config

Returns the current configuration object. If the configuration has not been initialized, it throws an error.

Example:

const currentConfig = configService.config;

get<K extends keyof Config>(key: K): Config[K]

Returns the value of a configuration parameter by its key. If the configuration has not been initialized, it throws an error.

  • key: the key whose value needs to be retrieved from the configuration.

Example:

const apiUrl = configService.get('apiUrl');

Errors

  • If you try to access the configuration before it is initialized, an error will be thrown: ConfigService is not initialized.
1.0.0-beta.33

5 months ago

1.0.0-beta.32

5 months ago

1.0.0-beta.28

9 months ago

1.0.0-beta.29

9 months ago

1.0.0-beta.26

9 months ago

1.0.0-beta.27

9 months ago

1.0.0-beta.31

9 months ago

1.0.0-beta.30

9 months ago

1.0.0-beta.22

9 months ago

1.0.0-beta.23

9 months ago

1.0.0-beta.20

9 months ago

1.0.0-beta.21

9 months ago

1.0.0-beta.19

9 months ago

1.0.0-beta.17

9 months ago

1.0.0-beta.18

9 months ago

1.0.0-beta.16

9 months ago

1.0.0-beta.24

9 months ago

1.0.0-beta.25

9 months ago

1.0.0-beta.15

9 months ago

1.0.0-beta.14

9 months ago

1.0.0-beta.10

9 months ago

1.0.0-beta.9

9 months ago

1.0.0-beta.8

9 months ago

1.0.0-beta.7

9 months ago

1.0.0-beta.6

9 months ago

1.0.0-beta.5

9 months ago