Code Monkey home page Code Monkey logo

url-shortener-microservice's Introduction

URL Shortener Microservice

Add any valid URL to the path of this domain and you'll receive a shortened URL in a JSON response. Navigating to the shortened URL will redirect you to the original URL.

Example

Let's say your server name is short.site. You can pass any valid URL as the first param in your browser.

https://short.site/https://www.somesuperlongwebsite.com/it/just/keeps/going&going=forever&ever=there%20must%20be%20a%20better%20way

Submitting this request to the server will return a JSON response with a new shortened link that will persist as long as the database is live. Submitting the link above will return:

{
  "__v": 0,
  "id": "jY73FvNy",
  "original_url": "https://www.somesuperlongwebsite.com/it/just/keeps/going&going=forever&ever=there%20must%20be%20a%20better%20way",
  "short_url": "short.site/B1P0re0s",
  "_id": "57d075cfb0d645f11a28e784"
}

Now, if you go to https://sort.site/jY73FvNy, you will get redirected to https://www.somesuperlongwebsite.com/it/just/keeps/going&going=forever&ever=there%20must%20be%20a%20better%20way. Much better!

If you're testing this out locally, the short_url property's value will be localhost/123abcYZ, but don't forget the port number when you try out the new shortened link. If process.env.PORT is undefined, the server will default to port 4000, so navigating to localhost:4000/123abcYZ will work.

Installation

  1. Clone this repository
  2. NPM install

Usage

  1. Open a new terminal window in the root of the project and run:
    npm run mongo
    This will start a local instance of mongodb. Make sure you have a directory named data in the root of your project. Keep this terminal open, and run the following command in a second terminal.
  2. gulp serve
    This will initiate gulp to start the express server along with nodemon.

.

url-shortener-microservice's People

Contributors

mtrifilo 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.