Skip to content

A full-stack URL shortening service that lets users shorten long URLs and track access counts, built with MongoDB, Express, Node.js, and a simple frontend UI.

Notifications You must be signed in to change notification settings

MHammad33/URL-Shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

URL Shortener

Description

A simple URL shortening service that allows users to shorten long URLs and track the access count. Built with Node.js, Express, and MongoDB.

Features

  • 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.

Setup Instructions

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v16 or above)
  • MongoDB (Running locally or use MongoDB Atlas)

Getting Started

  1. 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
  1. Set up environment variables: Create a .env file in the root directory and add the following:

    MONGODB_URL=<your_mongodb_connection_string>
    PORT=3000
    
  2. Run the application: To start the development server:

    npm run dev

    The app should now be running at http://localhost:3000.

Routes

  • 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"
    }
  • GET /api/urls - Get a list of all shortened URLs.
  • DELETE /api/urls/**:id** - Delete a URL by its ID.

Frontend

  1. Frontend setup:

    cd frontend
    npm install
  2. Run frontend development server:

    npm run dev

    The frontend app should now be running at http://localhost:5173.

Contributing

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-name).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature-name).
  5. Create a new Pull Request.

🛠 Note: All application code is on the dev branch. The main branch only contains this README.

About

A full-stack URL shortening service that lets users shorten long URLs and track access counts, built with MongoDB, Express, Node.js, and a simple frontend UI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •