GithubHelp home page GithubHelp logo

mayank-aggrwal / url-shortener Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 35 KB

Service to shorten long URLs into shorter ones.

Home Page: https://shortt-ly.herokuapp.com/

License: MIT License

JavaScript 100.00%
url-shortener shorten-urls shortener-rest shortening-urls

url-shortener's Introduction

๐Ÿ’ป SHORTT-LY (URL-Shortener)

A simple yet useful web service to compress long URLs into shorter ones.

Features

  1. General URL shortening
  2. Custom URL shortening
  3. Easy to integrate with other applications

Open Endpoints

  • Shorten given long URL : POST /api/short
  • Shorten URL with custom code : POST /api/custom
  • Redirect to website : GET /:code
  • Check API health : GET /health

POST /api/short

Request schema

{
    "longUrl": "<the-long-url-to-be-shortened>"
}

Response schema

{
  "_id": "5f81dca70f685f2f104",
  "longUrl": "<the-long-url-to-be-shortened>",
  "shortUrl": "https://<base-url>/-i8bZ5O9B",
  "urlCode": "-i8bZ5O9B",
  "date": "Sat Oct 10 2017 21:39:11 GMT+0530 (India Standard Time)",
  "__v": 0
}
{
  "errors": {
    "message": "Invalid long URL"
  }
}
{
  "errors": {
    "message": "Invalid base URL"
  }
}
{
  "errors": {
    "message": "Server error"
  }
}

POST /api/custom

Request schema

{
    "longUrl": "<the-long-url-to-be-shortened>",
    "urlCode": "<custom-code>"
}

Response schema

{
  "_id": "5f81dca70f685f2f104",
  "longUrl": "<the-long-url-to-be-shortened>",
  "shortUrl": "https://<base-url>/-i8bZ5O9B",
  "urlCode": "-i8bZ5O9B",
  "date": "Sat Oct 10 2017 21:39:11 GMT+0530 (India Standard Time)",
  "__v": 0
}
{
  "errors": {
    "message": "Code already in use"
  }
}
{
  "errors": {
    "message": "Invalid long URL"
  }
}
{
  "errors": {
    "message": "Invalid base URL"
  }
}
{
  "errors": {
    "message": "Server error"
  }
}

Instructions

  • Clone the repository
  • Install node from official website
  • Install the dependencies for the project using below command
    npm install
  • To run the application locally
    npm run dev
  • In the browser goto : http://localhost:5000/health

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Check Contributing.md for more instructions.

License

MIT

url-shortener's People

Contributors

mayank-aggrwal avatar

Stargazers

 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.