8000 GitHub - geetotes/cloudflare_storage: Simple gem for Cloudflare Workers KV reading and writing from Rails
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

geetotes/cloudflare_storage

Repository files navigation

CloudflareStorage

CloudflareStorage is a simple gem for interacting with the Cloudflare Workers KV Storage from a Rails application.

It was designed to let you get started with minimal configuration.

Read a more detailed writeup here.

Installation

Add this line to your application's Gemfile:

gem 'cloudflare_storage'

And then run:

bundle

Or install it yourself:

gem install cloudflare_storage 

Usage

Configure credentials with an initializer. For example:

# config/initializers/cloudflare_storage.rb
CloudflareStorage.configure do |config|
    config.account_id = Rails.application.credentials.cloudflare.account_id
    config.namespace_id = Rails.application.credentials.cloudflare.namespace_id
    config.token = Rails.application.credentials.cloudflare.token
  end
end

Now you can simply call CloudflareStorage in your code to read, write, and list from Workers KV storage. I.e.

CloudflareStorage.write('foo', 'bar')

CloudflareStorage.read('foo') # Returns 'bar'

CloudflareStorage.list('fo') # Lists all keys starting with 'fo'

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, then create a new git tag and push it. Github actions will take care of the rest.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/geetotes/cloudflare_storage.

License

The gem is available as open source under the terms of the MIT License.

Alternatives

There are other gems out there that encompass the whole of the Cloudflare API. You should look to those if you're planning on using more than just Workers KV storage in your project.

About

Simple gem for Cloudflare Workers KV reading and writing from Rails

Resources

License

Stars

Watchers

Forks

Packages

 
 
 
0