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.
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.
See RUNBOOK.md.