Git Product home page Git Product logo

url-shortener's Introduction

URL-Shortener

This project is a URL shortener service built with Node.js, Express, and MongoDB. It provides a RESTful API for creating short URLs from original URLs and redirecting from the short URLs to the original URLs.

Features

  • URL validation: Only valid URLs can be shortened.
  • Custom URL codes: Users can specify a custom code for their short URLs.
  • Persistent storage: Shortened URLs are stored in a MongoDB database.
  • Error handling: The service handles errors gracefully and returns appropriate HTTP status codes.

Getting Started

Prerequisites

  • Node.js
  • MongoDB

Installation

  1. Clone the repository:
    git clone https://github.com/Sergius-Nyah/url-shortener.git
    
  2. Navigate to the project directory:
    cd url-shortener
    
  3. Install the dependencies:
    npm install
    
  4. Start the server:
    npm start
    

Usage

To shorten a URL, send a POST request to the /shorten endpoint with a JSON body containing the originalUrl and an optional urlCode:

{
  "originalUrl": "https://example.com",
  "urlCode": "customCode"
}

The service will return a JSON object with the original URL, the short URL, and the URL code:

{
  "originalUrl": "https://example.com",
  "shortUrl": "http://short.url/customCode",
  "urlCode": "customCode"
}

To visit the original URL, simply navigate to the short URL in a web browser.

Contributing

Contributions are welcome! Please read our contributing guidelines to get started.

License

This project is licensed under the MIT License. See the LICENSE file for details.

url-shortener's People

Contributors

sergydwhiz avatar

Stargazers

Kartik Jain avatar Adrian avatar  avatar Reality Stevens avatar Skyino7 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.