A modern, free, fast, and open-source URL shortener built with TypeScript, Express, and MongoDB.
- π Fast & Lightweight - Built with performance in mind
- π URL Validation - Ensures only valid URLs are shortened
- π Click Tracking - Track how many times your short URLs are accessed
- π¨ Modern UI - Beautiful, responsive interface
- π Easy Sharing - One-click copy to clipboard
- π± Mobile Friendly - Works seamlessly on all devices
- π³ Docker Support - Easy deployment with Docker Compose
- π TypeScript - Fully typed for better development experience
- π Real-time Updates - See your URLs instantly after shortening
- π RESTful API - Full API for programmatic access
- Node.js (v18 or higher)
- MongoDB (local or cloud instance)
- npm or yarn
-
Clone the repository
git clone https://github.com/Vaporjawn/ShortURL.git cd ShortURL -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Edit
.envwith your configuration:PORT=5000 NODE_ENV=development MONGODB_URI=mongodb://localhost:27017/urlShortener BASE_URL=http://localhost:5000
-
Start MongoDB (if running locally)
mongod
-
Run the application
Development mode with hot reload:
npm run dev
Production mode:
npm run build npm start
-
Open your browser
Navigate to
http://localhost:5000
Run with Docker Compose (includes MongoDB):
docker-compose up -dThis will start both the application and MongoDB in containers.
POST /shortUrls
curl -X POST http://localhost:5000/shortUrls \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "fullUrl=https://example.com/very/long/url"GET /api/urls
curl http://localhost:5000/api/urlsResponse:
[
{
"_id": "...",
"full": "https://example.com/very/long/url",
"short": "abc123",
"clicks": 42,
"createdAt": "2025-10-08T00:00:00.000Z",
"updatedAt": "2025-10-08T00:00:00.000Z"
}
]GET /api/stats/:shortUrl
curl http://localhost:5000/api/stats/abc123Response:
{
"full": "https://example.com/very/long/url",
"short": "abc123",
"clicks": 42,
"createdAt": "2025-10-08T00:00:00.000Z",
"updatedAt": "2025-10-08T00:00:00.000Z"
}DELETE /api/urls/:shortUrl
curl -X DELETE http://localhost:5000/api/urls/abc123GET /:shortUrl
curl -L http://localhost:5000/abc123This will redirect to the original URL and increment the click counter.
- Backend: Node.js, Express.js, TypeScript
- Database: MongoDB with Mongoose ODM
- Frontend: EJS templating, Bootstrap 5
- URL Generation: ShortID
- Development: ts-node-dev, nodemon
- Code Quality: ESLint, TypeScript strict mode
ShortURL/
βββ src/
β βββ config/
β β βββ database.ts # MongoDB connection
β βββ middleware/
β β βββ errorHandler.ts # Error handling middleware
β βββ models/
β β βββ shortUrl.ts # URL model and schema
β βββ utils/
β β βββ logger.ts # Logging utility
β βββ server.ts # Main application entry
βββ views/
β βββ index.ejs # Home page
β βββ 404.ejs # 404 error page
βββ dist/ # Compiled TypeScript output
βββ .env.example # Environment variables template
βββ docker-compose.yml # Docker configuration
βββ tsconfig.json # TypeScript configuration
βββ package.json # Project dependencies
βββ README.md # This file
npm run dev- Start development server with hot reloadnpm run build- Build TypeScript to JavaScriptnpm start- Run production servernpm run lint- Lint code with ESLintnpm test- Run testsnpm run clean- Remove build artifacts
This project uses ESLint with TypeScript rules. Run npm run lint to check code style.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
See CONTRIBUTING.md for more details.
This project is licensed under the MIT License - see the LICENSE file for details.
Victor Williams
- GitHub: @Vaporjawn
- Email: victor.williams.dev@gmail.com
- Express.js - Fast, unopinionated web framework
- MongoDB - NoSQL database
- Bootstrap - CSS framework
- ShortID - Short ID generator
- User authentication and private URLs
- Custom short URL aliases
- QR code generation
- Analytics dashboard
- Rate limiting
- URL expiration
- API key authentication
- Bulk URL shortening
- URL preview before redirect
None at the moment. Please report issues on the GitHub Issues page.
If you have any questions or need help, please:
- Open an issue on GitHub
- Contact via email: victor.williams.dev@gmail.com
Made with β€οΈ by Victor Williams