StorageProvider

Abstract class for storage providers to extend. Provides runtime errors for missing method implementations, and is necessary at compile-time when using TypeScript for the compiler to recognize a StorageProvider as valid.

StorageProviders must present an interface with a storage solution that provides access to string values via string keys. Data will be stored in the storage solution by the framework as stringified JSON-valid data

Note: All methods shown on this class must be implemented within any storage providers you create and, in the case of keys() and get(), must return the proper data types or your client will not work.

Constructor

(abstract) new StorageProvider(name: string)

Parameters:
Name Type Description
name
string

Name of the storage to access. Can be a DB table, file name, etc. Whatever the storage solution expects with regards to providing a unique identifier for a specific storage.

Note: This does not need to be passed to super() in classes extending StorageProvider as StorageProvider is abstract and provides no implementation, but should be received by and used within your storage provider constructors as necessary to create a unique storage based on the given string

Implements:
Source:

Methods

.clear() → Promise<void>

Async method that removes all keys and their values from storage

Implements:
Source:
Returns:
Promise<void>

.get(key: string) → Promise<string>

Async method that gets the value of a key in storage

Parameters:
Name Type Description
key
string

The name of the key in storage

Implements:
Source:
Returns:
Promise<string>

.init() → Promise<void>

Async method to be run that will set up the storage provider for use. Calls to other provider methods should not be made until this method has been called and resolved

Implements:
Source:
Returns:
Promise<void>

.keys() → Promise<string[]>

Async method returning an array of stored key names

Implements:
Source:
Returns:
Promise<string[]>

.remove(key: string) → Promise<void>

Async method that removes a key and its value from storage

Parameters:
Name Type Description
key
string

The name of the key in storage

Implements:
Source:
Returns:
Promise<void>

.set(key: string, value: string) → Promise<void>

Async method that sets the value of a key in storage

Parameters:
Name Type Description
key
string

The name of the key in storage

value
string

The value to set in storage

Implements:
Source:
Returns:
Promise<void>