Skip to content

ayodeleoniosun/url-shortener

Repository files navigation

Url Shortener

Requirements

For development, you will only need Node.js, a node global package, npm, MySQL and Redis installed in your development environment.

Node

  • Node installation on Windows

    Visit official Node.js website and download the installer. Also, be sure to have git available in your PATH and npm (You can find git here).

  • Node installation on Ubuntu

    You can install nodejs and npm easily with apt install, just run the following commands.

    $ sudo apt install nodejs
    $ sudo apt install npm
    
  • Node installation on macOS

    You can install nodejs and npm easily with brew install, just run the following commands.

    $ brew install node
    

MySQL

Redis


Clone

$ git clone https://github.com/ayodeleoniosun/url-shortener.git
$ cd url-shortener

Configure app

  • Copy the contents of .env.sample to env - cp .env.sample .env

  • You can replace the database credentials where necessary

  • Create the database on your local MySQL instance

  • Run the setup.sh file in the project root.
    If you got a permission error, please run chmod +x setup.sh to change permission, then try again.
    The setup.sh file does the following:

    • Installs project Dependencies
    • Runs the Project Build
    • Runs the Database Migration

Run app

  • Run npm start to start the app (app runs on PORT 3000 by default).
  • Run npm run dev to start the app in development mode.
  • Run npm test to run test.
  • To test the api, kindly visit Here

Design & Implementation Decisions

  • Shortened URL was stored in both db and redis for faster access and better performance.