Skip to content

Latest commit

 

History

History
119 lines (79 loc) · 4.98 KB

README.md

File metadata and controls

119 lines (79 loc) · 4.98 KB

QuickLink - Simplify Long URLs in a Snap

QuickLink is a cutting-edge URL shortener project designed to simplify and streamline the process of sharing long and complex web addresses. With an intuitive and user-friendly interface, QuickLink empowers users to convert lengthy URLs into concise and easy-to-share short links effortlessly.

Key Features:

  • Fast and Efficient: QuickLink swiftly generates short URLs, allowing users to share links with lightning speed and convenience.
  • Custom Short URLs: Users have the option to create custom short URLs, providing a personalized touch to their links.
  • RESTful API: QuickLink offers a robust API for seamless integration with other applications and services.

API Reference

Resolve URL

GET /:url
Parameter Type Description
url string Required. Short URL to resolve

Shortens the provided URL and redirects to the original long URL.

Shorten URL

POST /api/v1
Parameter Type Description
url string Required. URL to shorten.
short string Custom short URL (Optional).
expiry time.Duration Expiry time for the short URL in hours (Optional).

Shortens the provided URL into a custom or autogenerated short link. It enforces rate limiting to avoid abuse.

The QuickLink API provides two main routes to handle URL shortening and resolution.

  1. Resolve URL: The GET route / followed by the short URL parameter (/:url) is used to resolve and redirect to the original long URL associated with the provided short URL. If the short URL is not found in the database or there are issues with the database connection, an appropriate error response is returned.

  2. Shorten URL: The POST route /api/v1 is used to shorten a given URL. It accepts a JSON request containing the original URL, an optional custom short URL, and an optional expiry duration. The API validates the input URL's format and checks if the domain is protected. It enforces HTTPS and SSL and generates a unique short link. If a custom short URL is provided, the API checks if it is already taken. The short URL is stored in the database with an optional expiry time. The API also implements rate limiting to prevent abuse of the service.

The API response includes the shortened URL, the custom short URL (if provided), the expiry duration (in hours), and the rate limit information (remaining requests and reset time in minutes). With these endpoints, users can effectively shorten and resolve URLs with ease and reliability.

Authors

Installation

Prerequisites

Before getting started with the QuickLink URL shortener app, ensure you have the following prerequisites installed on your system:

  1. Docker - A platform for developing, shipping, and running applications in containers.
  2. Node.js - A JavaScript runtime to run the client application.

Steps to Set Up QuickLink App

  1. Docker Setup:

    • Open a terminal or command prompt and navigate to the base folder of the project.
    • Ensure you have the .env file in the api folder with the following contents:
    DB_ADDR="db:6379"
    DB_PASS=""
    APP_PORT=":3000"
    DOMAIN="localhost:3000"
    API_QUOTA="10"
    
    • Run the following command to start the Redis database:
    docker-compose up -d

    This command will start the Redis database container in the background.

  2. Client Setup:

    • Once the Redis database is up and running, open another terminal or command prompt.
    • Navigate to the client folder of the project using the following command:
    cd client
    • Create a .env file in the client folder with the following content:
    VITE_BACKEND_URL=http://localhost:3000
    
    • Install the required dependencies by running:
    npm install
    • Start the client application by running:
    npm run dev

    The client application will start, and you can access it in your browser at the specified URL (usually http://localhost:3000).

  3. Usage:

    • With the QuickLink app running, you can now start shortening URLs and accessing their redirected long versions.
    • Use the provided API endpoints to interact with the URL shortening service programmatically.

By following these steps and ensuring you have the prerequisites installed and configuration files set up correctly, you'll have the QuickLink URL shortener app up and running on your local system. Happy shortening!

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.