A simple URL shortening service that allows users to shorten long URLs and track the access count. Built with Node.js, Express, and MongoDB.
- Shorten long URLs.
- Copy short URL to clipboard.
- View all shortened URLs with their access count.
- Delete a shortened URL.
- Toggle between Light and Dark mode.
Before you begin, ensure you have the following installed:
-
Clone the repository:
<<<<<<< HEAD <<<<<<< HEAD git clone https://github.com/MHammad33/URL-Shortener.git
git clone -b dev https://github.com/MHammad33/MuhammadHammad-innovaxel-Afzal.git
dev ======= git clone -b dev https://github.com/MHammad33/URL-Shortener.git dev
2. **Install dependencies:**
Navigate to the project directory and install the required packages:
```bash
<<<<<<< HEAD
cd URL-Shortener
=======
cd MuhammadHammad-innovaxel-Afzal
>>>>>>> dev
cd backend
npm install
-
Set up environment variables: Create a
.envfile in the root directory and add the following:MONGODB_URL=<your_mongodb_connection_string> PORT=3000 -
Run the application: To start the development server:
npm run dev
The app should now be running at
http://localhost:3000.
- POST /api/urls/shorten - Create a short URL.
- Body:
{ "originalUrl": "<your-original-url>" } - Response:
{ "id": "6804b2c59cfab173a40a13be", "originalUrl": "https://drive.google.com/file/d/1_Cg2gjDgmzE7FBEdcZTQ0Uknfiu6c9Le/view1121", "shortUrl": "56c5e120-1", "accessCount": 0, "createdAt": "2025-04-20T08:39:33.050Z", "updatedAt": "2025-04-20T08:39:33.050Z" } - Body:
- GET /api/urls - Get a list of all shortened URLs.
- DELETE /api/urls/**:id** - Delete a URL by its ID.
-
Frontend setup:
cd frontend npm install -
Run frontend development server:
npm run dev
The frontend app should now be running at
http://localhost:5173.
- Fork the repository.
- Create a new branch (
git checkout -b feature-name). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-name). - Create a new Pull Request.
🛠 Note: All application code is on the
devbranch. Themainbranch only contains this README.