@grammyjs/storage-free
Version:
Storage adapter for grammY's free sessions
36 lines (35 loc) • 1.32 kB
TypeScript
/**
* Options for creating a storage adapter.
*/
export interface StorageOptions {
/**
* The root URL of the storage backend. Useful if you want to host your own
* storage backend behind a different URL.
*/
rootUrl?: string;
/**
* A storage authentication token that will be used when authenticating at the
* backend. Note that the library will automatically renew the token if
* authentication fails. Hence, you will still need to provide the bot token.
*/
jwt?: string;
}
/**
* @param token The bot token of your bot.
* @param opts Further configuration options
* @returns An adapter to grammY's free session storage
*/
export declare function freeStorage<T>(token: string, opts?: StorageOptions): {
readAllKeys(): Promise<T>;
read(key: string): Promise<T>;
write(key: string, data: T): Promise<void>;
delete(key: string): Promise<void>;
/**
* Returns the storage authentication token which is used to store the
* session data. Only useful if you want to avoid the login call that will
* be performed automatically when the storage adapter contacts its backend
* for the first time. This can improve startup performance and is
* especially useful in serverless environments.
*/
getToken(): Promise<string>;
};