- TypeScript 97.1%
- JavaScript 1.5%
- Shell 1.4%
| .forgejo/workflows | ||
| .osf | ||
| e2e | ||
| openspec | ||
| scripts | ||
| src | ||
| test | ||
| .gitignore | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| package.json | ||
| playwright.config.ts | ||
| README.md | ||
| tsconfig.json | ||
| vitest.config.ts | ||
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
- Install dependencies:
npm install
- 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.
- 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