Git Product home page Git Product logo

shortlink's Introduction

About The Project

Shortlink App in Golang

  • Multiple Node based Architecture to create and scale at ease
  • Highly performant key-value storage system
  • Centralized Storage option when multiple node created - requires tweaking.
  • API auth system not built. Left for using it for your own use case like JWT or paseto. Self Implement.

Please see the architecture file in the repository on option you can use the app. For some minor tweaking may be required.

Built With

List of Library and Framework used in building the app:

Getting Started

Just download and run go run main.go and you are ready to go. To deploy to server, prefer DigitalOcean

Steps

Common Steps to Launch:

go mod tidy
go mod vendor
go run main.go OR go build -ldflags "-s -w" main.go && ./main

Must Changeable Variables in constant.go:

Production      = 2 // Please set to 1 if in production.
Domain          = "https://lin.ks/"
CookieName      = "lin.ks"
NodeID          = "N1|" // Increase per node by value as "N2|", "N3|"... for multiple node
DBFolder        = "/home/ubuntu/go/src/shortlink/db/"
AddFromToken    = 3 // firt N character to get from token and use it in ShortID
ShortIDToken    = 7 // Further added from 1st N char of AddFromToken+NodeID: total=12
APITokenLength  = 32
Click here to see Rest API Example:
  1. Short URL redirector: /:short_code_here
  2. API Routes:
  • /api/create [Post]
Takes `{"url": "https://github.com"}` with `Authorization: Bearer {token}` from Header
  • /api/update [Post]
Takes `{"old": "https://github.com", "new": "https://bitbucket.com", "short": "shortcode"}` with `Authorization: Bearer {token}` from Header
  • /api/delete [Post]
Takes `{ "long": "https://bitbucket.com", "short": "shortcode"}` with `Authorization: Bearer {token}` from Header
  • /api/fetch [GET]
 Takes `Authorization: Bearer {token}` from Header
  • /api/fetch/:short_code_here [GET]
 {short_code_here} in the URL and Takes `Authorization: Bearer {token}` from Header

Note: Remember to implement Auth system of your own and Replace APITokenLength check with your own function.

Please see the rest.http file to understand the request type in live details.

Feature request?

Share your feature request via issue tracker.

Feel like helping out:

  • Via Code Contribution (if any / new feature)
  • BTC: 1Hp24RtL3o86boapSAD3DtyqF5jdq1rfpM
  • Star the repository and watch out for new updates and features.

Do not Forget [ Shortlink App Plan ]

Following Use cases:

  • Self-Hosted URL tracking.
  • Your URL tracking insights is in-house and not hosted or shared with third party.

License

Distributed under the Apache License 2.0. See LICENSE for more information.

shortlink's People

Contributors

aschenmaker avatar krokite avatar rebootcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shortlink's Issues

BUG: write database del key, but read database didn't

if I del a shortlink use this post request,

{
  "long": "https://google.com",
  "short": "http://127.0.0.1/N1|12asdf1"
}

Absolutely it's a wrong use of this delete API, but it will return the response:

{
  "error": false,
  "message": "Successfully deleted",
}

When I try to use the shortlink again, it redirect successly. So we didn't remove the short code in pogreb database.

If you try to delete the shortcode use the right request again, it will go to fail. Because the longurl has already been deleted.

The shortlink can be used all the time.

I think Del the shortcode didn't return the error. So del the Long one, didn't del the shortcode in badger.

fix badgerInit Path

maybe fix path to "/badger"

opts := badger.DefaultOptions(helper.DBFolder + "badger")

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.