This project is a URL shortener built using Node.js, Express.js, and MongoDB. It allows users to shorten long URLs into concise links for easy sharing.
- Node.js and npm (or yarn)
- MongoDB
- A code editor
- Clone the repository:
git clone https://github.com/kanavbajaj/URL-Shortener.git
- Navigate to the project directory:
cd url-shortener
- Install dependencies:
npm install
- Start the MongoDB server.
- Run the application:
npm start
The application will be accessible at http://localhost:your_port_number
.
- POST /shortUrls
- Request body:
{ "fullUrl": "https://www.example.com/long-url" }
- Response:
{ "short": "http://localhost:your_port_number/shortened-url" }
- Request body:
- GET /:shortUrl
- Redirects to the original URL.
The MongoDB database will contain a collection with the following schema:
{
"full": "https://www.example.com/long-url",
"short": "shortened-url",
"clicks": "Number Of Clicks"
}
Contributions are welcome! Please open an issue or pull request if you have any improvements or new features.