feat: add alias support for short URLs - #30
Conversation
Introduces the test harness (vitest, an in-memory Postgres via pg-mem, and `test`/`test:watch` scripts) with no real DB or secrets required, so future features can ship with unit tests. Included a UrlService smoke-test suite covering existing create/read/update/delete/search/sort/click-count behavior as the first consumer of the harness. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Lets a short URL have any number of aliases — alternate codes that redirect to the same destination (new url_aliases table). Aliases resolve exactly like the primary code, share the aggregate click_count, and additionally track their own click count/last-click time. Adds: - Alias chip inputs in the create dialog and a "Manage aliases" dialog (add/remove, per-route click stats, promote-to-primary) reachable from each URL row. - An editable short code in the edit dialog (rename), rejecting collisions and pointing users at "promote" if they try to rename onto their own alias. - POST/DELETE /urls/:shortCode/aliases, POST .../promote, and GET .../alias-stats REST endpoints; createUrl/updateUrl bodies gain `aliases: string[]`. Scoped down from vigab.cc's version: that implementation merges two URLs when an alias collides with an existing primary code (transferring click history and tags). This port simply rejects the collision with a clear error — merging is complex, edge-case-heavy behavior that isn't needed for a first cut, and it also assumed the tags feature. Can be added later if wanted. Likewise, promote here doesn't remap analytics scopes, since this PR is independent of the analytics PR (#29) by design. Builds on the vitest/pg-mem test infrastructure branch for its test suite. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 21 minutes Limit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (17)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
url_aliasestable: each URL can have any number of alternate short codes that redirect to the same destination. Aliases resolve exactly like the primary code (getUrlByShortCode/redirect matches either), andurls.click_countstays the aggregate total across the primary code + all aliases (atomically incremented alongside the alias's own counter), while each alias also tracks its ownclick_count/last_clicked_at.POST/DELETE /urls/:shortCode/aliases,POST /urls/:shortCode/aliases/:aliasCode/promote,GET /urls/:shortCode/alias-stats;createUrl/updateUrlbodies gainaliases: string[].Scope decisions
url_aliases/urls— no analytics coupling.Test plan
pnpm test— 15 tests pass (alias CRUD, collision rejection, rename, promote with click-history transfer, reconcile-on-update)pnpm check(biome) passespnpm buildsucceeds