New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/tauadam/url-shortener-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tauadam/url-shortener-api

  • v0.0.0-20240831215644-ce4d510140d3
  • Source
  • Go
  • Socket score

Version published
Created
Source

Description:

Rest API for shortening urls

Self-hosting instructions:

  1. Clone the repository
  2. Install dependencies
    go mod download
    
  3. Run the server
    make run
    
  4. Run the tests
make tests

Save alias

  • POST /
      {
        "url": "https://www.google.com",
        "alias": "google"
      }
    

Delete alias

  • DELETE /:alias

Go to the shortcut link

  • GET /:alias

Features:

  • Redirect to the original url by the short url
  • If alias is not provided, generate a random alias
  • Creating, deleting urls are protected by auth
    • basic http auth
  • To store data use sqlite database
  • Api tries to decode json body, if it fails, returns failed to parse request message
  • Validates incoming requests
  • Logs all requests in text format in dev environment, and in json format in prod environment
  • Saving existing url, returns the same name message
  • Fails if alias is invalid
  • Fails if URL for given alias not found
  • Redirect only if successfully got URL

img.png Tests shows that api works correctly

FAQs

Package last updated on 31 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc