Coder Social home page Coder Social logo

go-mini-url's Introduction

Go miniURL

A URL minifier REST API written in Go, with Gin framework

Stack

Packages

Environment Variables

  • APP_MODE=development | production
  • PORT=4000
  • DATABASE_URI=<your mongodb uri>
  • DATABASE_NAME=<your mongodb collection name>
  • JWT_ISSUER=
  • JWT_SECRET=
  • EMAIL_VERIFICATION_TOKEN_SECRET=
  • HASH_COST=10

larger HASH_COST will result in slower but more secure hashing

Getting Started

  • Clone the repo and run go get to install all the dependencies.
  • Create a .env file at the root of the project and add the above mentioned variables.
  • Run go run . to start the project in debug mode. It is a good idea to set APP_MODE=development.
  • Request the following endpoints from either your own UI or Postman.

Endpoints

Common prefix – /api

Authentication

Common prefix – /auth

Login

Register

Reset Password

  • Get link
  • Set new password

Validate user token

Minify

Common prefix – /minify

Get all minified urls

Request

curl --location --request GET 'http://localhost:4000/api/minify'

Response

[
  {
    "_id": "6598609d7d1a137466f0f8eb",
    "label": "Official Go Website",
    "active": true
  }
]

Generate new minified URL

Request

Payload

{
  "link": "https://go.dev",
  "label": "Official Go Website"
}
curl --location --request POST 'http://localhost:4000/api/minify' \
--header 'Content-Type: application/json' \
--data '{
	"link": "https://go.dev",
	"label": "Official Go Website"
}'

Get single minified url

Sending a request to this endpoint will redirect to the original url that was minified.

curl --location --request GET 'http://localhost:4000/api/minify/65985472c4fd59a24436a281'

Update a url

Delete a url

go-mini-url's People

Contributors

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