2
2
3
3
[ ![ Commitizen Friendly] ( https://img.shields.io/badge/commitizen-friendly-brightgreen.svg )] ( http://commitizen.github.io/cz-cli/ )
4
4
[ ![ License] ( https://img.shields.io/github/license/0-vortex/workers-url-shortener )] ( ./LICENSE )
5
+ [ ![ FOSSA Status] ( https://app.fossa.com/api/projects/git%2Bgithub.com%2F0-vortex%2Fworkers-url-shortener.svg?type=shield )] ( https://app.fossa.com/projects/git%2Bgithub.com%2F0-vortex%2Fworkers-url-shortener?ref=badge_shield )
6
+
7
+ [ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/26ea74df7c6fe2f18438/maintainability )] ( https://codeclimate.com/github/0-vortex/workers-url-shortener/maintainability )
8
+ [ ![ Known Vulnerabilities] ( https://snyk.io/test/github/0-vortex/workers-url-shortener/badge.svg )] ( https://snyk.io/test/github/0-vortex/workers-url-shortener )
5
9
6
10
## Overview
7
11
8
- TBD
12
+ A Cloudflare Workers script to use as a simple redirect system.
13
+
14
+ The [ data.json] ( ./src/data.json ) file can be used as dummy input or `` git `` enabled backup for your production environment.
15
+
16
+ The motivation for doing such a thing is GUI or IAM enabled acces to these variables from other CloudFlare tools, essentially promoting observability.
9
17
10
18
## Folder structure
11
19
@@ -88,6 +96,46 @@ gh repo clone 0-vortex/workers-url-shortener
88
96
89
97
## Usage
90
98
99
+ ### Configure KV
100
+
101
+ To successfully run the redirect worker we need to set up some KV namespaces.
102
+
103
+ Generate new ` namespace_id ` s for the KV keys it [ wrangler.toml] ( ./wrangler.toml ) and follow the instructions:
104
+
105
+ ``` shell
106
+ # dev environment
107
+ wrangler kv:namespace create " REDIRECTS"
108
+ wrangler kv:namespace create " REDIRECTS" --preview
109
+ ```
110
+
111
+ ``` shell
112
+ # production environment
113
+ wrangler kv:namespace create " REDIRECTS" --env production
114
+ wrangler kv:namespace create " REDIRECTS" --env production --preview
115
+ ```
116
+
117
+ After you are done editing check if the changes are correct:
118
+
119
+ ``` shell
120
+ wrangler kv:namespace list
121
+ ```
122
+
123
+ ### Test data
124
+
125
+ Upload some data to the `` REDIRECTS `` namespace:
126
+
127
+ ``` shell
128
+ # dev environment
129
+ wrangler kv:bulk put --binding=" REDIRECTS" ./src/data.json
130
+ wrangler kv:bulk put --binding=" REDIRECTS" ./src/data.json --preview
131
+ ```
132
+
133
+ ``` shell
134
+ # production environment
135
+ wrangler kv:bulk put --binding=" REDIRECTS" ./src/data.json --env production
136
+ wrangler kv:bulk put --binding=" REDIRECTS" ./src/data.json --env production --preview
137
+ ```
138
+
91
139
### Local development
92
140
93
141
To develop locally just run:
@@ -113,3 +161,5 @@ wrangler tail
113
161
## License
114
162
115
163
This library is released under BSD-3 license clause.
164
+
165
+ [ ![ FOSSA Status] ( https://app.fossa.com/api/projects/git%2Bgithub.com%2F0-vortex%2Fworkers-url-shortener.svg?type=large )] ( https://app.fossa.com/projects/git%2Bgithub.com%2F0-vortex%2Fworkers-url-shortener?ref=badge_large )
0 commit comments