npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sync-to-kv

v0.0.3

Published

Push the contents of a folder to Cloudflare KV.

Downloads

69

Readme

sync-to-kv

Push the contents of a folder to Cloudflare KV.

If you have a nice little static website, and you want to host the files somewhere, you can shove them in CFKV to be accessed by a small fast Worker.

Install

The usual way (global for CLI access):

npm install -g sync-to-kv

How to Use

You will need the KV "Namespace ID", and some environment variables:

  • CF_ACCOUNT_ID - Your Cloudflare account id.
  • CF_NAMESPACE_ID - The "Namespace ID" of that KV store.
  • Either this one (recommended):
  • Or this one:
    • CF_AUTH_EMAIL - Your Cloudflare account email address.
    • CF_AUTH_KEY - Your global API key.

(Note: the CLOUDFLARE_ prefix is also supported.)

Then you simply run the command like this:

sync-to-kv ./path/to/folder

Additional Options

You can run --help for more details, but the flags you can pass in are:

  • -i, --ignore : Ignore one or more files, using glob syntax. Example -i='**/*.test.js'.
  • -p, --prefix : This is a prefix used for partitioning groups of KV entries within the same store. E.g. site A may use -p='a:' while site B may use -p='b:'.
  • -f, --file (default file:) : Prefix used for all file entries, e.g. a file index.html with the default prefix (file:) would be stored with a key file:index.html.
  • -h, --hash (default hashes) : Name used to store the dictionary hash map of key names to hashes, which is used to improve upload time.
  • -d, --dryrun : Just print out what would have been updated or removed, but do not actually update KV.

Examples

If you have a folder like site and you want to exclude all *.test.js files, you would write something like:

sync-to-kv ./site -i '**/*.test.js'

If you have multiple sites in one KV store, it might be good to store them by domain name, so your --prefix would be the domain:

sync-to-kv ./site -p site.com

Here's a longer example with many flags:

sync-to-kv ./site \
  -i '**/*.test.js' \
  -i '**/*.md' \
  -i '.DS_Store' \
  -p site.com \
  -f 'bin:' \
  -h 'hashmap'

License

Published and released under the Very Open License.