Skip to content

lebedevilya/shortlink

Repository files navigation

ShortLink

ShortLink is a URL shortening service built with Ruby on Rails. It provides a minimal UI plus a JSON API for encoding and decoding URLs. Short links are persisted in SQLite so they survive restarts.

image

API

POST /encode

Request:

{ "url": "https://codesubmit.io/library/react" }

Optional expiration:

{ "url": "https://codesubmit.io/library/react", "expires_in_days": 90 }

Use "never" or "infinity" to disable expiration:

{ "url": "https://codesubmit.io/library/react", "expires_in_days": "never" }

Response:

{ "url": "https://codesubmit.io/library/react", "short_url": "http://localhost:3000/GeAi9K", "expires_at": "2025-02-25T10:20:30Z" }

POST /decode

Request:

{ "short_url": "http://localhost:3000/GeAi9K" }

Response:

{ "url": "https://codesubmit.io/library/react", "short_url": "http://localhost:3000/GeAi9K", "expires_at": "2025-02-25T10:20:30Z" }

Expired links return 410 Gone.

The base short URL defaults to the request host. Override it with APP_SHORT_URL_HOST to return a custom domain. Expiration defaults to 1 month. Override it with APP_DEFAULT_EXPIRATION_DAYS, use expires_in_days/expires_at per request, or "never"/"infinity" for non-expiring links.

Rate limiting defaults to 100 requests per 60 seconds per IP. Override with APP_RATE_LIMIT_MAX_REQUESTS and APP_RATE_LIMIT_WINDOW_SECONDS.

Run Instructions

See RUNBOOK.md.

About

simple url shortener

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors