Code Monkey home page Code Monkey logo

linkify's Introduction

link shortener

The purpose of a link shortener is to reduce url length by converting a full url to smaller footprint. This smaller footprint is easier to share in social media and can also include third-party analytics.

There are two common ways to shorten links:

  1. Hashing or encoding the full url using a algorithm like base64 or MD5
  2. Create a random, unique link id and saving the link id for use during link resolution

In both cases, a route will need to handle the translation from shortened link to full link.

encoding

I chose to create a link id for a few reasons:

  • The request had specific length and character requirements for the shortened url and I did not want to create a special hashing function
  • Hashing has a small chance of two urls colliding (very unlikely but possible with shorter lengths)
  • Creating a link id allows for very small urls -- the algorithm I chose can be modified to shrink links further than the requested 6 characters
  • Storing the link information in a database allows us to extend the shortener to other useful features
    • Expiring old links
    • Tracking analytics data on link creation
    • Allowing short links with specific words or characters

resolution

The easiest form of link resolution is to return a HTTP 302 response. An alternative would be using an HTML redirect for browsers that accept HTML and only use a 302 response for non-HTML browsers but there are few reasons to do so.

setup

To run the project you will need access to a DynamoDB table and the appropriate AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. You can add them as envrionment variables or to a Docker compose override file. Tests run against DynamoDB Local but still require AWS key/secret due to how the AWS SDK works.

To start the api:

  • docker-compose build api
  • docker-compose up api

To run tests:

  • docker-compose build test
  • docker-compose up test

linkify's People

Contributors

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