PURISTA API / Modules / @purista/core / DefaultConfigStore
Class: DefaultConfigStore
@purista/core.DefaultConfigStore
The DefaultConfigStore is a placeholder which offers all needed methods. Getters and setters will throw a UnhandledError with status Unauthorized
, when a disabled operation is called.
For development and testing purpose, you can initiate the store with values.
Example
const store = new DefaultConfigStore({
enableGet: true,
enableRemove: true,
enableSet: true,
config: {
initialValue: 'initial',
},
})
console.log(await store.getConfig('initialValue') // outputs: { initialValue: 'initial' }
Hierarchy
ConfigStoreBaseClass
<DefaultConfigStoreConfig
>↳
DefaultConfigStore
Implements
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new DefaultConfigStore(config?
): DefaultConfigStore
Parameters
Name | Type | Description |
---|---|---|
config? | Object | - |
config.cacheTtl? | number | Cache time to live in ms |
config.enableCache? | boolean | Enable cache |
config.enableGet? | boolean | Enable generally get method |
config.enableRemove? | boolean | Enable generally remove method |
config.enableSet? | boolean | Enable generally set method |
config.logLevel? | LogLevelName | A log level for new logger if logger is not set |
config.logger? | Logger | A logger instance |
Returns
Overrides
ConfigStoreBaseClass.constructor
Defined in
DefaultConfigStore/DefaultConfigStore.impl.ts:30
Properties
cache
• cache: ConfigStoreCacheMap
Inherited from
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:26
config
• config: Object
Type declaration
Name | Type | Description |
---|---|---|
cacheTtl? | number | Cache time to live in ms |
enableCache? | boolean | Enable cache |
enableGet? | boolean | Enable generally get method |
enableRemove? | boolean | Enable generally remove method |
enableSet? | boolean | Enable generally set method |
logLevel? | LogLevelName | A log level for new logger if logger is not set |
logger? | Logger | A logger instance |
Inherited from
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:22
logger
• logger: Logger
Inherited from
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:21
map
• Private
map: Map
<string
, unknown
>
Defined in
DefaultConfigStore/DefaultConfigStore.impl.ts:29
name
• name: string
name of store
Implementation of
Inherited from
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:24
Methods
destroy
▸ destroy(): Promise
<void
>
disconnects and shuts down the config store
Returns
Promise
<void
>
Implementation of
Inherited from
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:126
getConfig
▸ getConfig<ConfigNames
>(...configNames
): Promise
<ObjectWithKeysFromStringArray
<ConfigNames
>>
Returns the values for given config properties. This function SHOULD NOT be overwritten by store implementation. For implementation overwrite protected getConfigImpl
Type parameters
Name | Type |
---|---|
ConfigNames | extends string [] |
Parameters
Name | Type |
---|---|
...configNames | ConfigNames |
Returns
Promise
<ObjectWithKeysFromStringArray
<ConfigNames
>>
an object of
Implementation of
ConfigStore.getConfig
Inherited from
ConfigStoreBaseClass.getConfig
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:62
getConfigImpl
▸ getConfigImpl<ConfigNames
>(...configNames
): Promise
<ObjectWithKeysFromStringArray
<ConfigNames
>>
This method must be overwritten by actual store implementation.
Type parameters
Name | Type |
---|---|
ConfigNames | extends string [] |
Parameters
Name | Type | Description |
---|---|---|
...configNames | ConfigNames | list of config items |
Returns
Promise
<ObjectWithKeysFromStringArray
<ConfigNames
>>
an object of
Overrides
ConfigStoreBaseClass.getConfigImpl
Defined in
DefaultConfigStore/DefaultConfigStore.impl.ts:40
removeConfig
▸ removeConfig(configName
): Promise
<void
>
Removes the config item given by config name. This function SHOULD NOT be overwritten by store implementation. For implementation overwrite protected removeConfigImpl
Parameters
Name | Type |
---|---|
configName | string |
Returns
Promise
<void
>
Implementation of
ConfigStore.removeConfig
Inherited from
ConfigStoreBaseClass.removeConfig
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:89
removeConfigImpl
▸ removeConfigImpl(configName
): Promise
<void
>
This method must be overwritten by actual store implementation.
Parameters
Name | Type |
---|---|
configName | string |
Returns
Promise
<void
>
Overrides
ConfigStoreBaseClass.removeConfigImpl
Defined in
DefaultConfigStore/DefaultConfigStore.impl.ts:61
setConfig
▸ setConfig(configName
, configValue
): Promise
<void
>
Sets a config value This function SHOULD NOT be overwritten by store implementation. For implementation overwrite protected setConfigImpl
Parameters
Name | Type |
---|---|
configName | string |
configValue | unknown |
Returns
Promise
<void
>
Implementation of
ConfigStore.setConfig
Inherited from
ConfigStoreBaseClass.setConfig
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:116
setConfigImpl
▸ setConfigImpl(configName
, configValue
): Promise
<void
>
This method must be overwritten by actual store implementation.
Parameters
Name | Type |
---|---|
configName | string |
configValue | unknown |
Returns
Promise
<void
>
Overrides
ConfigStoreBaseClass.setConfigImpl