No description
  • TypeScript 97.1%
  • JavaScript 1.5%
  • Shell 1.4%
Find a file
openspec-flow 12e754af7a
All checks were successful
CI / Release notes (push) Successful in 12s
CI / Browser tests (push) Successful in 1m11s
CI / Unit tests (push) Successful in 1m18s
Archive let-a-link-be-deleted-from-shortcut-the-6r94hs
2026-10-17 03:47:52 +00:00
.forgejo/workflows chore: CI, and a Postgres for the tests [skip ci] 2026-10-16 10:45:12 -04:00
.osf docs: run summary 2026-10-17 03:47:37 +00:00
e2e apply: implement the change and its tests 2026-10-17 03:45:59 +00:00
openspec Archive let-a-link-be-deleted-from-shortcut-the-6r94hs 2026-10-17 03:47:52 +00:00
scripts chore: CI, and a Postgres for the tests [skip ci] 2026-10-16 10:45:12 -04:00
src apply: implement the change and its tests 2026-10-17 03:45:59 +00:00
test apply: implement the change and its tests 2026-10-17 03:45:59 +00:00
.gitignore chore: CI, and a Postgres for the tests [skip ci] 2026-10-16 10:45:12 -04:00
AGENTS.md propose: the change, its specs, its tasks and its estimate 2026-10-16 15:07:05 +00:00
CHANGELOG.md apply: implement the change and its tests 2026-10-16 17:27:02 +00:00
package.json apply: implement the change and its tests 2026-10-16 17:27:02 +00:00
playwright.config.ts apply: implement the change and its tests 2026-10-16 17:27:02 +00:00
README.md apply: implement the change and its tests 2026-10-17 03:45:59 +00:00
tsconfig.json apply: implement the change and its tests 2026-10-16 17:27:02 +00:00
vitest.config.ts apply: implement the change and its tests 2026-10-17 03:45:59 +00:00

Shortcut

A small, private link shortener for one team. A form turns a long URL into a 6-character code (http/https URLs of at most 2,000 characters; anything else is refused with a message saying why), a visit to /<code> redirects (302) to the stored URL, and the Links page lists every link newest first with its code, URL, and click count. Each row of the Links page has a Delete button whose in-page confirmation ("Delete this link?", Delete or Cancel) removes the link, and the page then shows "Deleted ." once at the top; a deleted code answers the 404 "link does not exist" page, and visits to it count no click. Built as one small Node 22 / TypeScript HTTP server (no web framework) with plain-HTML pages, storing links and click counts in Postgres via the pg package.

Run

  1. Install dependencies: npm install
  2. Point DATABASE_URL at a reachable Postgres, e.g. postgres://app:app@127.0.0.1:5432/app. In this repository, scripts/services.mjs starts an embedded Postgres and writes DATABASE_URL for test runs.
  3. Start the server: npm start. It listens on PORT (default 3000); open http://localhost:3000/ for the shorten form and http://localhost:3000/links for the link list. Tables are created on start if missing.

Tests

The unit tests (vitest) run against the Postgres named by DATABASE_URL; if that is not set, npm test starts the embedded Postgres the repository bundles for the run and stops it when the tests finish:

npm test

The browser tests (Playwright, chromium) start the server themselves; install the browser once, then:

npx playwright install chromium
npm run test:e2e