Giter Site home page Giter Site logo

kikobeats / cloudflare-workers-kv Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 6.0 72 KB

Node.js library to interact with CloudFlare Workers KV.

Home Page: http://nicedoc.io/Kikobeats/cloudflare-workers-kv

License: MIT License

JavaScript 100.00%
cloudflare cloudflare-workers cloudflare-api key-value-store key-value-database

cloudflare-workers-kv's Introduction

@kikobeats/cloudflare-workers-kv

Last version Coverage Status NPM Status

Node.js library to interact with CloudFlare Workers KV.

Deprecation note: this library uses CloudFlare REST API that is slow. You should to use runtime API to interact the most optimal way.

CloudFlare Workers KV is faster <key, value> storage that runs on top of CloudFlare Network to offer a geo-distributed service almost free or reasonable cheaper.

Use it in combination with CloudFlare Workers or AWS Lambda to have a truly serverless database access, where the value will be serve from the nearest edge node, being the lowest response latency possible.

Install

$ npm install @kikobeats/cloudflare-workers-kv --save

Usage

The library is a convenient way to interact with CloudFlare Workers KV via usinng CloudFlare Workers KV API.

const cloudFlareWorkersKV = require('@kikobeats/cloudflare-workers-kv')
const ms = require('ms')

const store = cloudFlareWorkersKV({
  accountId: '<Cloudflare-Account-Id>',
  key: '<Cloudflare-API-Key>',
  namespaceId: '<Cloudflare-Workers-KV-Namespace-Id>'
})

async function examples () {
  // get a value
  await store.get('foo')

  // set a value forever
  await store.set('foo', 'bar')

  // set a value associating with a time-to-live associated
  await store.set('foo', 'bar', ms('5m'))

  // delete a value
  await store.delete('foo')
}

Authentication

At CloudFlare dashboard, enter to Your Profile > API Token > Create Token.

Then use CloudFlare Workers template and ensure at least the permission Workers KV Storage is present.

The API token provided should be provided as key.

License

@kikobeats/cloudflare-workers-kv © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats

cloudflare-workers-kv's People

Contributors

dependabot-preview[bot] avatar kikobeats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cloudflare-workers-kv's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.