const kvMonitor = new WorkersKvMonitor();
const workersKv = new WorkersKv(process.env["CF_EMAIL"], process.env["CF_ACCOUNT_ID"], process.env["CF_GLOBAL_API_KEY"], true, kvMonitor.dbListener.bind(kvMonitor));
An email of the Cloudflare account
An Id of the Cloudflare account
Optional
isValidateCfResponse: boolean = trueOptional
Rest
...extensionArg: Function[]Extensional function that is wanted to be executed after the database operation is performed
Private
cfRemove a KV pair from the Namespace. Use URL-encoding to use special characters (e.g. :, !, %) in the key name.
deleteKeyValuePair
https://api.cloudflare.com/#workers-kv-namespace-delete-key-value-pair
True if the key is successfully removed, false otherwise.
The Kv operation request is failed.
The parameters in the relative path
The name of the key
The namespace identifier
Private
extensionPrivate
isReturns the value associated with the given key in the given namespace. Use URL-encoding to use special characters (e.g. :, !, %) in the key name. If the KV-pair is set to expire at some point, the expiration time as measured in seconds since the UNIX epoch will be returned in the "Expiration" response header.
readKeyValuePair
https://api.cloudflare.com/#workers-kv-namespace-read-key-value-pair
The key value.
The Kv operation request is failed.
The parameters in the relative path
The name of the key
The namespace identifier
Write a value identified by a key. Use URL-encoding to use special characters (e.g. :, !, %) in the key name. Body should be the value to be stored. Existing values and expirations will be overwritten. If neither expiration nor expiration_ttl is specified, the key-value pair will never expire. If both are set, expiration_ttl is used and expiration is ignored.
writeKeyValuePair
https://api.cloudflare.com/#workers-kv-namespace-write-key-value-pair
True if key is successfully modified or added, false otherwise.
The Kv operation request is failed.
Parameters in the relative path
The name of the key
The namespace identifier
A UTF-8 encoded string to be stored, up to 10 MB in length.
Optional
urlParam: { expiration?: number; expiration_ttl?: number }The parameters at the end of URL
Optional
expiration?: numberThe time, measured in number of seconds since the UNIX epoch, at which the key should expire.
Optional
expiration_The number of seconds for which the key should be visible before it expires. At least 60.
Private
bridgePrivate
Handling a database operation that wants to be performed. It conveys a database operation request to the fetch function, receives a response from the fetch function, and send the whole database operation information to the funcArgHandlers for extensional purpose.
bridge
A full information about the HTTP request, database operation perform status, and other Cloudflare responses
Information about the requested database operation
Data related to the db operation for the HTTP request
Creates a namespace under the given title. A 400 is returned if the account already owns a namespace with this title. A namespace must be explicitly deleted to be replaced.
createNamespace
https://api.cloudflare.com/#workers-kv-namespace-create-a-namespace
Information about the new namespace.
The Kv operation request is failed.
Data for the HTTP body that will send to Cloudflare
A human-readable string name for a Namespace.
Remove a KV pair from the Namespace. Use URL-encoding to use special characters (e.g. :, !, %) in the key name.
deleteKeyValuePair
https://api.cloudflare.com/#workers-kv-namespace-delete-key-value-pair
True if the key is successfully removed, false otherwise.
The Kv operation request is failed.
The parameters in the relative path
The name of the key
The namespace identifier
Remove multiple KV pairs from the Namespace. Body should be an array of up to 10,000 keys to be removed.
deleteMultipleKeyValuePairs
https://api.cloudflare.com/#workers-kv-namespace-delete-multiple-key-value-pairs
True if keys are successfully removed, false otherwise.
The Kv operation request is failed.
The parameters in the relative path
The namespace identifier
The data that will send to Cloudflare
The name of the key
Protected
funcSending a database operation information to the function placed in the extensionArg in the class constructor
funcArgHandlers
True if the database operation is completed successfully, false otherwise. Null if it is uncertain that whether the operation is completed successfully or not.
Information about the requested database operation
A full information about the HTTP request, database operation perform status, and other Cloudflare responses
The error detail of the database operation
Private
genParsing and returning the Cloudflare response.
genReturnFromCfRes
A Cloudflare result that is shorten and pretty formatted.
The Kv operation request is failed.
A desired Cloudflare response format
A full information about the HTTP request, database operation perform status, and other Cloudflare responses
A short description of the performed operation.
Lists a namespace's keys.
listNamespaceKeys
https://api.cloudflare.com/#workers-kv-namespace-list-a-namespace-s-keys
A list of namespace's key as well as the page and cursor information.
The Kv operation request is failed.
Parameters in the relative path
The namespace identifier
Optional
urlParam: { cursor?: string; limit?: number; prefix?: string }The parameters at the end of URL
Optional
cursor?: stringOpaque token indicating the position from which to continue when requesting the next set of records if the amount of list results was limited by the limit parameter. A valid value for the cursor can be obtained from the cursors object in the result_info structure.
Optional
limit?: numberThe number of keys to return. The cursor attribute may be used to iterate over the next batch of keys if there are more than the limit.
Optional
prefix?: stringA string prefix used to filter down which keys will be returned. Exact matches and any key names that begin with the prefix will be returned.
Returns the namespaces owned by an account
listNamespaces
https://api.cloudflare.com/#workers-kv-namespace-list-namespaces
Information about the new namespace.
The Kv operation request is failed.
Optional
urlParam: { direction?: "asc" | "desc"; order?: "id" | "title"; page?: number; per_page?: number }The parameters that are in the URL
Optional
direction?: "asc" | "desc"Direction to order namespaces
Optional
order?: "id" | "title"Field to order results by
Optional
page?: numberPage number of paginated results
Optional
per_Returns the metadata associated with the given key in the given namespace. Use URL-encoding to use special characters (e.g. :, !, %) in the key name.
readKeyMeta
https://api.cloudflare.com/#workers-kv-namespace-read-the-metadata-for-a-key
An object containing the key and value of the metadata.
The Kv operation request is failed.
Parameters in the relative path
The name of the key
The namespace identifier
Returns the value associated with the given key in the given namespace. Use URL-encoding to use special characters (e.g. :, !, %) in the key name. If the KV-pair is set to expire at some point, the expiration time as measured in seconds since the UNIX epoch will be returned in the "Expiration" response header.
readKeyValuePair
https://api.cloudflare.com/#workers-kv-namespace-read-key-value-pair
The key value.
The Kv operation request is failed.
The parameters in the relative path
The name of the key
The namespace identifier
Deletes the namespace corresponding to the given ID.
removeNamespace
https://api.cloudflare.com/#workers-kv-namespace-remove-a-namespace
True if the namespace is successfully removed, false otherwise.
The Kv operation request is failed.
Parameters in the relative path
The namespace identifier
Modifies a namespace's title.
renameNamespace
https://api.cloudflare.com/#workers-kv-namespace-rename-a-namespace
True if the namespace is successfully renamed, false otherwise.
The Kv operation request is failed.
Parameters in the relative path
The namespace identifier
Data for the HTTP body that will send to Cloudflare
A human-readable string name for a Namespace.
Write a value identified by a key. Use URL-encoding to use special characters (e.g. :, !, %) in the key name. Body should be the value to be stored. Existing values and expirations will be overwritten. If neither expiration nor expiration_ttl is specified, the key-value pair will never expire. If both are set, expiration_ttl is used and expiration is ignored.
writeKeyValuePair
https://api.cloudflare.com/#workers-kv-namespace-write-key-value-pair
True if key is successfully modified or added, false otherwise.
The Kv operation request is failed.
Parameters in the relative path
The name of the key
The namespace identifier
A UTF-8 encoded string to be stored, up to 10 MB in length.
Optional
urlParam: { expiration?: number; expiration_ttl?: number }The parameters at the end of URL
Optional
expiration?: numberThe time, measured in number of seconds since the UNIX epoch, at which the key should expire.
Optional
expiration_The number of seconds for which the key should be visible before it expires. At least 60.
Write a value identified by a key. Use URL-encoding to use special characters (e.g. :, !, %) in the key name. Body should be the value to be stored along with json metadata to be associated with the key/value pair. Existing values, expirations and metadata will be overwritten. If neither expiration nor expiration_ttl is specified, the key-value pair will never expire. If both are set, expiration_ttl is used and expiration is ignored.
writeKeyValuePairMeta
https://api.cloudflare.com/#workers-kv-namespace-write-key-value-pair-with-metadata
True if key is successfully modified or added, false otherwise.
The Kv operation request is failed.
The parameters in the relative path
The name of the key
The namespace identifier
The data that will send to Cloudflare
Arbitrary JSON to be associated with a key/value pair
A byte sequence to be stored, up to 10 MB in length.
Optional
urlParam: { expiration?: number; expiration_ttl?: number }The parameters at the end of URL
Optional
expiration?: numberThe time, measured in number of seconds since the UNIX epoch, at which the key should expire.
Optional
expiration_The number of seconds for which the key should be visible before it expires. At least 60.
Write multiple keys and values at once. Body should be an array of up to 10,000 key-value pairs to be stored, along with optional expiration information. Existing values and expirations will be overwritten. If neither expiration nor expiration_ttl is specified, the key-value pair will never expire. If both are set, expiration_ttl is used and expiration is ignored. The entire request size must be 100 megabytes or less.
writeMultipleKeyValuePairs
https://api.cloudflare.com/#workers-kv-namespace-write-multiple-key-value-pairs
True if keys are successfully modified or added, false otherwise.
The Kv operation request is failed.
The parameters in the relative path
The namespace identifier
The data that will send to Cloudflare
Perform Kv database operations