Add v1 shortener: Bearer API, public 302, landing, and CI.
CI / test (pull_request) Successful in 6s

Standalone Django service so callers can mint links and phones get a 302.
Closes #1.
This commit is contained in:
2026-08-30 06:54:32 -05:00
parent 4baaa4b33c
commit 143ac7c6d0
48 changed files with 3469 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
"""DEBUG-only form to mint a short link without curling the API."""
from django.conf import settings
from django.contrib import messages
from django.http import Http404
from django.shortcuts import render
from django.views.decorators.http import require_http_methods
from links.forms import DebugCreateForm
from links.services import CodeCollisionError, create_link
@require_http_methods(["GET", "POST"])
def debug_create(request):
if not settings.DEBUG:
raise Http404()
form = DebugCreateForm(request.POST or None)
created_link = None
if request.method == "POST" and form.is_valid():
try:
created_link, minted = create_link(
target_url=form.cleaned_data["target_url"],
title=form.cleaned_data.get("title") or "",
external_ref=form.cleaned_data.get("external_ref") or "",
expires_at=None,
token_name="debug",
)
except CodeCollisionError:
form.add_error(None, "Could not allocate a unique code.")
else:
if minted:
messages.success(request, "Short link created.")
else:
messages.info(request, "Existing active link returned (same URL + ref).")
return render(
request,
"links/debug_create.html",
{"form": form, "created_link": created_link},
)