feat: add local KV instance support with --local flag #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature: Local KV Instance Support
Problem
When running
wrangler devfor local development, users had no way to easily post data to the local KV instance. The namespace ID is the same for both local and remote, making it confusing which endpoint is being used.Solution
Add a
--local/-lflag that switches between local and remote KV endpoints:-l):http://localhost:8787(wrangler dev)-l):https://api.cloudflare.com/client/v4(production)Usage Examples
Changes
--local/-lflag to CLIClientConfigto support local/remote switchingdocs/LOCAL_KV_DEVELOPMENT.mdPrerequisites
wrangler devmust be running for local operationsTesting
Files Changed
crates/cloudflare-kv/src/types.rs- Addedis_localandbase_url()methodcrates/cloudflare-kv/src/client.rs- Added local/remote endpoint testscrates/cfkv/src/cli.rs- Added--localflag to CLIcrates/cfkv/src/main.rs- Apply local flag to KvClient configdocs/LOCAL_KV_DEVELOPMENT.md- New comprehensive development guide