Giter Site home page Giter Site logo

the-shortest-url's Introduction

The Shortest Url

URL shortening service developed using Node.js and Express.js.

Before Running

There are a few things that have to be installed in the machine for the project to run correctly:

Once MySQL is installed, make sure to create a new database in the MySQL console with the command:

create database the_shortest_url;

Running The Project

After cloning the project with git clone https://github.com/leoruas/the-shortest-url.git, navigate to the cloned folder with:

cd the-shortest-url

Now that you're in the folder, install the project's dependencies with:

npm install

Once the installation is finished, update the environment variables in the .env file located in the root of the project. Default values are:

MYSQL_USER=root
MYSQL_PASSWORD=
MYSQL_DATABASE=the_shortest_url
MYSQL_HOST=localhost
MYSQL_PORT=3306

The project can now be executed with the command:

npm start

After running the execute command, you should see a message on the terminal saying: Server running on port 3000

Encode Route

The encode route is the POST request responsible for receiving the original url, storing it in the database and encoding it. This route requires a JSON on the body of the request with the following format:

{
  url: "https://codesubmit.io/library/react"
}

Once you send the url, the API will return a shortened version of it as seen in the following image: Request made on Postman for the encode route

Decode Route

The decode route is the GET request responsible for receiving the shortened link, decoding it and searching the database for the original link. This route requires a JSON on the body of the request with the following format:

{
  url: "https://short.link/HsUba"
}

Once you send the url, the API will return the original version of it as seen in the following image: Request made on Postman for the decode route

the-shortest-url's People

Contributors

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