A simple URL shortener service built with Express.js, SQLite, and Zod for validation.
- Shorten long URLs to unique short codes
- Validate URLs using Zod
- In-memory SQLite database
- Modern UI with error handling
- TypeScript support
- Install dependencies:
npm install
- Start the server:
# Development mode with auto-reload
npm run dev
# Production mode
npm start
- Open http://localhost:3000 in your browser
-
POST /shorten
- Body:
{ "originalUrl": "https://example.com" }
- Returns:
{ "shortUrl": "abc123" }
- Body:
-
GET /:shortUrl
- Redirects to the original URL
- Returns 404 if URL not found
The project uses:
- Express.js for the server
- SQLite for data storage
- Zod for validation
- TypeScript for type definitions
See nginx.conf
and url-shortener.service
for inspiration on deployment config.