Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Zertz/cloudflare-kv
Thin wrapper for Cloudflare Workers KV
https://github.com/Zertz/cloudflare-kv
Last synced: 27 days ago
JSON representation
Thin wrapper for Cloudflare Workers KV
- Host: GitHub
- URL: https://github.com/Zertz/cloudflare-kv
- Owner: Zertz
- License: mit
- Created: 2018-10-13T20:23:46.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-02-04T06:07:08.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T10:28:59.360Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 198 KB
- Stars: 20
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# cloudflare-kv
[![npm](https://badgen.net/npm/v/cloudflare-kv)](https://www.npmjs.com/package/cloudflare-kv) [![bundlephobia](https://badgen.net/bundlephobia/minzip/cloudflare-kv)](https://bundlephobia.com/result?p=cloudflare-kv)
> Thin wrapper for [Cloudflare Workers KV](https://developers.cloudflare.com/workers/learning/how-kv-works)
## Installation
> Requires Node.js 14 and up
`npm install cloudflare-kv` **or** `yarn add cloudflare-kv`
## Usage
### Environment variables
```
CLOUDFLARE_ACCOUNT_ID=
CLOUDFLARE_TOKEN=
CLOUDFLARE_NAMESPACE_ID=
``````js
import CloudflareKV from "cloudflare-kv";const kv = new CloudflareKV();
```### Local variables
```js
const CloudflareKV = require("cloudflare-kv");const kv = new CloudflareKV({
accountId: "",
apiToken: "",
namespaceId: "",
});
```### Writing, reading and deleting data
```js
await kv.put("key", { workers: "kv" });const value = await kv.get("key");
// { workers: "kv" }await kv.delete("key");
```## Development
```
yarn
yarn test --watch
```## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://github.com/Zertz/cloudflare-kv/blob/master/license)