https://github.com/blooym/workerlink
[Mirror] Serverless link shortener for Cloudflare Workers & KV.
https://github.com/blooym/workerlink
cloudflare-kv cloudflare-workers link-shortener
Last synced: 6 days ago
JSON representation
[Mirror] Serverless link shortener for Cloudflare Workers & KV.
- Host: GitHub
- URL: https://github.com/blooym/workerlink
- Owner: Blooym
- License: apache-2.0
- Created: 2023-09-11T04:11:03.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-08T22:29:19.000Z (about 1 month ago)
- Last Synced: 2025-10-04T01:56:50.406Z (6 days ago)
- Topics: cloudflare-kv, cloudflare-workers, link-shortener
- Language: Rust
- Homepage: https://codeberg.org/Blooym/workerlink
- Size: 209 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Workerlink
A serverless URL shortener built on Cloudflare Workers & Cloudflare KV.
## Deployment
In order to deploy workerlink to Cloudflare Workers, you need to do the following:
1. Clone this repository locally with git or by downloading the source archive.
2. Download and install [NodeJS](https://nodejs.org) and [Rust v1.85.0+](https://rustup.rs/), or use the provided [.devcontainer](.devcontainer) setup for an environment.
3. Run `npm install` to install all dependencies needed to build/deploy.
4. [Setup a KV namespace](https://developers.cloudflare.com/kv/get-started/) on Cloudflare by following their documentation.
5. Create a 'wrangler.toml' file with the following contents at the root of the repository:
```toml
name = "workerlink"
main = "build/worker/shim.mjs"
compatibility_date = "2024-11-11"
kv_namespaces = [
{ binding = "links", id = "" } # Replace with the ID of the KV namespace you setup earlier.
][vars]
AUTH_TOKEN = "" # Set this to the token you want to use for authentication.[build]
command = "cargo install -q worker-build && worker-build --release"
```
6. Run `npm run deploy` to deploy the worker to Cloudflare; You will be prompted to authenticate with Cloudflare during this process so the worker can be deployed using your account.## Examples
- **In a browser:** Use a redirect.
Navigate to `https:///` and the browser will automatically direct.- **In a browser:** See where an ID redirects to.
Navigate to `https:////where` and the redirect url will be shown in plaintext.- **Using curl:** Create/Update a new redirect.
```bash
curl --request POST \
--url 'https:///' \
--header 'Authorization: ' \
--header 'content-type: application/json' \
--data '{
"url": "",
"expiry_timestamp": unix_timestamp | null,
"max_views": number | null,
"overwrite": boolean,
"disabled": boolean
}'
```- **Using curl:** Delete an existing redirect.
```bash
curl --request DELETE \
--url 'https:///' \
--header 'Authorization: '
```- **Using curl:** Check the underlying JSON of a redirect.
```bash
curl 'https:////details' \
--header 'Authorization: '
```## License
This project is dual-licensed under both the MIT License and the Apache License (Version 2.0). See [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) for more details.