Skip to content

Create and manage shortened URLs effortlessly with this URL Shortener project. Built using Node.js and MongoDB, this service allows users to convert long URLs into concise, shareable links. The intuitive API offers endpoints for both shortening and redirecting URLs. Contribute to the project.

Notifications You must be signed in to change notification settings

UjjS/URL-Shortener

Repository files navigation

URL Shortener

This is a simple URL shortener service that allows users to create short versions of long URLs.

Features

  • Shorten long URLs into easy-to-share shortened URLs.
  • Redirect users from the shortened URL to the original long URL.

Getting Started

Follow these instructions to set up and run the URL shortener on your local machine.

Prerequisites

  • Node.js installed on your machine.
  • MongoDB installed and running locally.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/url-shortener.git
    
  2. Change into the project directory:

    cd url-shortener
    
  3. Install dependencies:

    npm install
    
  4. Create a .env file in the project root and add the following:

    PORT=5000 
    MONGO_URI=mongodb://localhost:27017/url-shortener
    BASE_URL=http://localhost:5000
    
  5. Start the server:

    npm start
    

API Endpoints

POST /api/url/shorten: Shorten a long URL.

Request Body:

{
  "longUrl": "https://example.com/your-long-url"
  "shortUrl": "http://localhost:5000/abc123",
  "urlCode": "abc123",
  "date": "2023-01-01T12:00:00.000Z",
  "_id": "1234567890"
}


   

About

Create and manage shortened URLs effortlessly with this URL Shortener project. Built using Node.js and MongoDB, this service allows users to convert long URLs into concise, shareable links. The intuitive API offers endpoints for both shortening and redirecting URLs. Contribute to the project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published