Skip to content

Thedevelop3r/url-shortner

Repository files navigation

URL Shortener Microservice

This is the boilerplate code for the URL Shortener Microservice project. Instructions for building your project can be found at https://www.freecodecamp.org/learn/back-end-development-and-apis/back-end-development-and-apis-projects/url-shortener-microservice.


URL Shortener

This project is a solution to a FreeCodeCamp challenge for building a URL shortener service. It uses Node.js, Express, and MongoDB (via Mongoose) to provide a simple web API for shortening URLs. The application includes additional logic and packages to meet challenge requirements and all tests have been passed.

Features

  • Shorten long URLs to concise short links
  • Store and retrieve URLs using MongoDB with Mongoose
  • RESTful API endpoints
  • Fully passes FreeCodeCamp test suite

Getting Started

Prerequisites

  • Node.js (v14 or later)
  • npm
  • MongoDB (local or Atlas)

Installation

  1. Clone the repository:

    git clone https://github.com/Thedevelop3r/url-shortner.git
    cd url-shortner
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    Create a .env file in the root directory and add your MongoDB URI:

    MONGO_URI=your_mongodb_connection_string
    PORT=3000
    
  4. Start the application:

    npm start

    The server will run on http://localhost:3000 by default.

API Endpoints

  • POST /api/shorturl

    • Request Body: { "url": "https://example.com" }
    • Response: { "original_url": "https://example.com", "short_url": 1 }
  • GET /api/shorturl/:short_url

    • Redirects to the original URL corresponding to the provided short URL code.

Technologies Used

  • JavaScript (Node.js, Express)
  • MongoDB & Mongoose
  • CSS (for any frontend)
  • Shell scripts (for automation tasks)

License

This project is open-source and available under the MIT License.

About

this project was a challenge at freecodecamp for url shortning | i used mongoose as database some extra packages and wrote its logic , passed the test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors