Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
added KV Namespace support with wrangler 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldridge Alexander committed Aug 19, 2019
1 parent d63e40f commit 604af43
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

<a href="https://lillink.co">Live Demo</a>

Before deploying you'll need to put your info into the `zone_id`, `account_id`, and `route` sections of `wrangler.toml`
Before deploying you'll need to put your info into the `zone_id`, `account_id`, `route`, and `[[kv-namespaces]]` sections of `wrangler.toml` To deploy with Wrangler, you'll need at least version 1.2.0.

Requires 2 Workers KV Namespaces, currently hardcoded as `SHORTLINKS` and `HITS`.
The shortlink is currently used as the key for both.
This requires 2 Workers KV Namespaces, mapped to `SHORTLINKS` and `HITS`.
The shortlink is currently used as the key for both.

HITS currently doesn't display data anywhere but collects hit counts for future usage.

Expand All @@ -19,5 +19,14 @@ HITS currently doesn't display data anywhere but collects hit counts for future
| HITS | shortlink | hit count |


Currently the KV Namespaces must be setup and connected to this script manually. There is currently a
<a href="https://github.com/cloudflare/wrangler/tree/feat-better-kv">feature branch</a> of the <a href="https://github.com/cloudflare/wrangler">wrangler tool</a> that supports configuring this in the wrangler.toml file. Once this has been merged to `master` I'll be integrating it into this.
This version adds support for handling KV Namespaces via Wrangler.

## Configuration and Deployment
1. Run `git clone https://github.com/eldridgea/lil-link`
2. Create 2 KV Namespaces in the Cloudflare Dashboard or via their API.
3. Fill out the `zone_id`, `account_id`.
4. Fill out the `route` section of `wrangler.toml` with `https://example.com/&ast;`, replacing "example.com" with your domain.
5. Paste one of your newly created KV Namespace IDs into `wrangler.toml` under `SHORTLINKS` and the other under `HITS`
6. `cd` into the lil-link directory and run `wrangler publish --release`

*Note: I have been unable to get Workers run unless there is already an active DNS record in the Cloudflare dashboard. I have an A record for `@` on lillink.co pointing to a server I control, but as my route is set to `https://lillink.co/&ast;` supposedly the server will never be contacted as Workers will intercept all requests.*
7 changes: 7 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ zone_id = ""
private = false
account_id = ""
route = ""

[[kv-namespaces]]
binding = "HITS"
id = ""
[[kv-namespaces]]
binding = "SHORTLINKS"
id = ""

0 comments on commit 604af43

Please sign in to comment.