Skip to content

feat(links): generate short codes for new links - #47

Merged
brennenho merged 1 commit into
brennen/demo-mainfrom
brennen/demo-ctc-39
Nov 19, 2026
Merged

brennenho merged 1 commit into
brennen/demo-mainfrom
brennen/demo-ctc-39

Conversation

@brennenho

Copy link
Copy Markdown
Contributor

Summary

Signed-in callers can now send { "url": "https://example.com" } to POST /api/links and receive the saved row in a 201 response as { link }. The tool page can use link.code to build the short URL. CTC-39

Changes

  • Generate a 12-character hexadecimal code when the caller omits code.
  • Use the existing D1 primary key to detect collisions during insertion. Generated codes get up to five attempts. An explicitly requested code gets one attempt and returns the existing 409 error when taken.
  • Update the API example and cover generated responses, successful retries, and exhausted retries against local D1.

Testing

  • pnpm check passed formatting, lint, type checking, and all 99 tests.
  • Applied the existing migrations to local D1 and signed in to the local Next.js app. Posted a URL without a code, received 201, and fetched the same saved row by the returned code.
  • Created a custom code and title, then posted the same code with a different destination. The API returned 409, and a subsequent GET returned the original row.
  • Verified an invalid URL and an empty explicit code each returned 400, and a signed-out POST returned 401.

@linear-code

linear-code Bot commented Nov 19, 2026

Copy link
Copy Markdown

CTC-39

@github-actions
github-actions Bot temporarily deployed to pr-47 November 19, 2026 04:16 Destroyed
@github-actions

Copy link
Copy Markdown

Preview deployment

Open preview ↗

Last deployed 2026-11-19T04:17:25Z

Commit Workflow
f6cd6f3 Run #74 · attempt 1

Fallback preview

@brennenho
brennenho added this pull request to stack #53 November 19, 2026 04:23
@brennenho
brennenho marked this pull request as ready for review November 19, 2026 04:23
@brennenho
brennenho requested review from a team as code owners November 19, 2026 04:23
@brennenho
brennenho merged commit 31020ea into brennen/demo-main Nov 19, 2026
2 checks passed
@brennenho
brennenho deleted the brennen/demo-ctc-39 branch November 19, 2026 04:24

This branch was successfully deployed

No deployments
pr-47 — f6cd6f3f Deployed Nov 19, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant