Simple URL Shortener
zlink is a simple, fast URL shortener built with Node.js, Express, and TypeScript. It exposes a REST API and a clean web UI.
- Shorten any
http://orhttps://URL to a compact 7-character code - Instant redirect when visiting a short link
- Visit stats for every short link
- Simple, responsive web UI
- Node.js 18+
- npm
npm install
npm run build
npm startThe server starts on http://localhost:3000 (override with PORT env var).
npm install
npm run dev # runs with ts-node (no build step required)npm testShorten a URL.
Request body
{ "url": "https://example.com/very/long/path" }Response 201
{
"code": "aBcD123",
"shortUrl": "http://localhost:3000/aBcD123",
"originalUrl": "https://example.com/very/long/path"
}Redirects (HTTP 301) to the original URL.
Returns visit statistics.
Response 200
{
"code": "aBcD123",
"originalUrl": "https://example.com/very/long/path",
"createdAt": "2024-01-01T00:00:00.000Z",
"visits": 42
}zlink/
├── src/
│ ├── app.ts # Express app setup
│ ├── routes.ts # API route handlers
│ ├── server.ts # HTTP server entry point
│ ├── store.ts # In-memory link store
│ └── types.ts # TypeScript interfaces
├── public/
│ ├── index.html # Web UI
│ └── 404.html # Not-found page
└── tests/
└── app.test.ts # Integration tests