Skip to content

sheygs/shortlink-api

Repository files navigation

shortlink-api

Short link is a URL shortening service.

Overview

ShortLink is a URL shortening service where you enter a URL such as https://indicina.co and it returns a short URL such as http://short.est/GeAi9K. Visiting the shortened URL should redirect the user to the long URL. Using the example above, visiting http://short.est/GeAi9K should redirect the user to https://indicina.co

Features

  • encode: Encode a URL to a shortened URL
  • decode: Decodes a shortened URL to its original URL
  • statistic/{url_path}: Return the basic statistics of a short URL path. Using the above link, url_path will be GeAi9K.

Project Structure

Overall, the project is designed to be scalable, maintainable and extensible. The use of a monolithic architecture that can easily spin off to a micro-service following modular architecture pattern that promotes code organization and separation of concerns.

Tech Stack

Requirements

Rename .env.sample to .env and replace the placeholders

PORT=XXXX
NODE_ENV=development

Postman Documentation

  • Navigate to http://localhost:8282/api-docs on your computer to view the openapi documentation.

Installation 📦

Without Docker

   $ git clone https://github.com/sheygs13/shortlink-api.git
   $ cd shortlink-api
   $ npm install
  • Run npm install to install project dependencies
  • Run npm run dev to run the services and you are good
  • Open browser and visit http://localhost:8282

Docker

  • Install Docker
  • Run docker-compose up -d. But If you like to see those clumsy logs 😬, RUN docker-compose up
  • Open browser and visit http://localhost:8282

Production Packaging

  • RUN npm run prod to start the production build
docker build -t ${IMAGETAG} -f Dockerfile .

Test

   $ npm test