This is a simple link shortener service using CloudFlare Workers and KV. The idea is simple, create short URLs and collect how many of the URLs are visited.
Postman documentation: here
Features:
- Basic authentication using API key
- Create/delete/get short URL detail and hit count
- Get total hits, total success and failed hits
- Clone this repo
- Login using
wrangler login - Create two KV namespace
npx wrangler kv:namespace create SHORT_URLSandSHORT_URL_STATS - Copy the binding code to the
wrangler.toml, replace the old value there - Update the
HOMEPAGE_URLto your main site (this is the default redirect) - Update the
HOST_URLto your domain/subdomain for this worker - Create
.dev.varsand add this line:AUTH_KEY=<random key here> - Deploy the worker
npm run deploy
Easy peasy, right?