Giter Site home page Giter Site logo

shorten-url's Introduction

Project Title

URL Shortner

Description

A simple URL shortning API with functionality similar to TinyURL. We use Redis as a local db for v1.

Getting Started

Dependencies

  • GoLang - go version go1.19.3
  • Docker
  • github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
  • github.com/go-redis/redis/v8 v8.11.5
  • github.com/gofiber/fiber/v2 v2.51.0

Installing

  • Clone repo to your local machine.
  • CD into ./shorten-url directory and run the following command to install dependencies.
go mod tidy
  • Any modifications needed to be made to files/folders

Executing program

  • from the ./shorten-url directory level run docker containers using the following command
docker-compose up -d

Using the API

  • After the container is running with the db and the api images, use a service like Postman to make a POST call to http://127.0.0.1:3000/api/v1

  • Provide a JSON body like the one below. custom_short and expiry are optional.

{
    "url":"https://medium.com/rupesh-tiwari/publishing-merged-code-coverage-report-of-nx-workspace-in-azure-ci-pipeline-70b44dbff1d9",
    "custom_short" : "mycoolerdomain",
    "expiry": 100
}
  • A successfull request will result in something like this
{
    "URL": "https://medium.com/rupesh-tiwari/publishing-merged-code-coverage-report-of-nx-workspace-in-azure-ci-pipeline-70b44dbff1d9",
    "CustomShort": "localhost:3000/mycoolerdomain",
    "Expiry": 100,
    "XRateRemaining": 93,
    "XRateLimitReset": 25
}

  • If the `custom_short`` value has already been used before, you will see an error message like the one below:
{
    "error": "Custom short URL already in use."
}

Authors

Contributors names and contact info

ex. Abraham Fong ([email protected])

Version History

  • 0.1
    • Initial Release

shorten-url's People

Watchers

Abraham Fong 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.