From 60ebac71501d4874edd61705b22fdd74a9f00f7c Mon Sep 17 00:00:00 2001 From: sjdonado Date: Sun, 16 Mar 2025 14:21:36 +0100 Subject: [PATCH] chore: update API docs --- README.md | 12 ++++++------ app/controllers/ping.cr | 2 +- docs/API.md | 28 +++++++++++----------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index afd5694..4ec3475 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,18 @@ [![Docker Stars](https://img.shields.io/docker/stars/sjdonado/bit.svg)](https://hub.docker.com/r/sjdonado/bit) [![Docker Image Size](https://img.shields.io/docker/image-size/sjdonado/bit/latest)](https://hub.docker.com/r/sjdonado/bit) -# Bit URL Shortener - Lightweight URL shortener service with minimal resource requirements. Average memory consumption is **20MB RAM** with container disk space under **50MB**. Bit is highly performant, achieving over 1.8K requests per second with an average latency of 68ms. For detailed benchmark results, see [benchmark](docs/SETUP.md#benchmark). Images available on [Docker Hub](https://hub.docker.com/r/sjdonado/bit/tags). -## Quick Start -```bash -docker run -p 4000:4000 -e ADMIN_API_KEY=$(openssl rand -base64 32) sjdonado/bit:latest -``` +## Why Bit? +It is feature-complete by design. Its strength lies in simplicity, a reliable URL shortener without unnecessary bloat. Bug fixes will continue, but new features aren't planned. + +- Minimal tracking setup: Country, browser, os, referer. No cookies or persistent tracking mechanisms are used beyond what's available from a basic client's request. +- Flexible request forwarding system passes client context (IP, user-agent) to destinations via standard X-Forwarded-For and X-Forwarded-User-Agent headers, enabling advanced tracking and integration capabilities when needed. +- Multiple users are supported via API key authentication. Create, list and delete via the [CLI](docs/SETUP.md#cli). ## Minimum Requirements - 50MB disk space diff --git a/app/controllers/ping.cr b/app/controllers/ping.cr index ef527d7..e73554d 100644 --- a/app/controllers/ping.cr +++ b/app/controllers/ping.cr @@ -3,7 +3,7 @@ require "../lib/controller.cr" module App::Controllers::Ping class Get < App::Lib::BaseController def call(env) - response = {"pong" => "ok"} + response = {"data" => "pong"} response.to_json end end diff --git a/docs/API.md b/docs/API.md index 8053c18..261ca24 100644 --- a/docs/API.md +++ b/docs/API.md @@ -7,7 +7,7 @@ - Response Example ```json { - "message": "pong" + "data": "pong" } ``` @@ -15,7 +15,7 @@ - Endpoint: `GET /:slug` - Payload: None - - Response 301 + - Response: 301 3. **List All Links** @@ -34,10 +34,10 @@ { "id": "730e2202-58f9-478c-a24c-f1c561df6716", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0", - "language": "en-US", + "country": "DE", "browser": "Firefox", "os": "Mac OS X", - "source": "Unknown", + "referer": "Direct", "created_at": "2024-07-12T19:25:22Z" } ] @@ -62,10 +62,10 @@ { "id": "730e2202-58f9-478c-a24c-f1c561df6716", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0", - "language": "en-US", + "country": "DE", "browser": "Firefox", "os": "Mac OS X", - "source": "Unknown", + "referer": "Direct", "created_at": "2024-07-12T19:25:22Z" } ] @@ -89,7 +89,7 @@ "data": { "id": "84f0c7a4-8c4e-4665-b676-cb9c5e40f1db", "refer": "http://localhost:4000/3wP4BQ", - "origin": "https://monocuco.donado.co/test", + "origin": "https://example.com", "clicks": [] } } @@ -119,13 +119,7 @@ 7. **Delete a link by ID** - - Endpoint: `DELETE /api/links/:id` - - Payload: None - - Headers: `X-Api-Key` - - Response Example: - ```json - { - "message": "Link deleted" - } - ``` - + - Endpoint: `DELETE /api/links/:id` + - Payload: None + - Headers: `X-Api-Key` + - Response: 204