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.
- 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.
GET /:url
Parameter | Type | Description |
---|---|---|
url |
string |
Required. Short URL to resolve |
Shortens the provided URL and redirects to the original long 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.
-
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. -
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.
Before getting started with the QuickLink URL shortener app, ensure you have the following prerequisites installed on your system:
- Docker - A platform for developing, shipping, and running applications in containers.
- Node.js - A JavaScript runtime to run the client application.
-
Docker Setup:
- Open a terminal or command prompt and navigate to the base folder of the project.
- Ensure you have the
.env
file in theapi
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.
-
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 theclient
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
). -
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!
Contributions are always welcome!
See contributing.md
for ways to get started.
Please adhere to this project's code of conduct
.