Skip to content

A simple URL shortener service powered by Cloudflare Workers and Turso.

License

Notifications You must be signed in to change notification settings

arcestia/shortlink

Repository files navigation

URL Shortener Service

A simple URL shortener service powered by Cloudflare Workers and Turso.

URL Shortener Interface

Features

  • Create short URLs with random keys
  • Create custom short URLs
  • Authorization required for creating URLs
  • Beautiful UI with dark mode support
  • Redirect to default URL when form is disabled
  • Modern, responsive interface with TailwindCSS
  • ShareX integration support

Tech Stack

Development

  1. Clone the repository:

    git clone https://github.com/yourusername/shortlink.git
    cd shortlink
  2. Install dependencies:

    npm install
  3. Create a .dev.vars file with your environment variables:

    WORKERLINKS_SECRET=your_secret
    TURSO_DB_URL=your_turso_db_url
    TURSO_DB_AUTH_TOKEN=your_turso_auth_token
  4. Start the development server:

    npm run dev

Deployment

  1. Install Wrangler CLI:

    npm install -g wrangler
  2. Configure your secrets in Cloudflare:

    npx wrangler secret put WORKERLINKS_SECRET
    npx wrangler secret put TURSO_DB_URL
    npx wrangler secret put TURSO_DB_AUTH_TOKEN
  3. Deploy to Cloudflare Workers:

    npm run deploy

ShareX Integration

You can use this URL shortener with ShareX for quick sharing. Create a new custom uploader in ShareX with the following configuration:

{
  "Version": "16.1.0",
  "Name": "Shlink v3 Shortener",
  "DestinationType": "URLShortener",
  "RequestMethod": "POST",
  "RequestURL": "https://skiddle.link/api/links",
  "Headers": {
    "Authorization": "mysecret",
    "Content-Type": "application/json"
  },
  "Body": "JSON",
  "Data": "{\n  \"url\": \"{input}\"\n}",
  "URL": "{json:shorturl}"
}

To set up:

  1. Open ShareX
  2. Go to Destinations > Custom Uploader Settings
  3. Click "Import" > "From Clipboard"
  4. Paste the configuration above
  5. Replace mysecret with your actual authorization token
  6. Set as default URL shortener in ShareX settings

API Usage

Create Random Short URL

curl -X POST https://your-domain.com/api/links \
  -H "Content-Type: application/json" \
  -H "Authorization: your_secret" \
  -d '{"url":"https://example.com"}'

Response:

{
  "message": "URL created successfully",
  "key": "abc123",
  "shorturl": "https://your-domain.com/abc123",
  "longurl": "https://example.com"
}

Create Custom Short URL

curl -X PUT https://your-domain.com/api/links/custom-path \
  -H "Content-Type: application/json" \
  -H "Authorization: your_secret" \
  -d '{"url":"https://example.com"}'

Response:

{
  "message": "URL created successfully",
  "key": "custom-path",
  "shorturl": "https://your-domain.com/custom-path",
  "longurl": "https://example.com"
}

License

MIT License - see LICENSE for details

Credits

Created and maintained by Laurensius Jeffrey

About

A simple URL shortener service powered by Cloudflare Workers and Turso.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published