Generate short links with either custom aliases or randomly generated short codes.
Set an optional expiration date for each URL. Links without expiration remain active indefinitely.
Track the total number of clicks on each short URL and view detailed stats.
Secure registration and login using JWT-based authentication for managing user-specific URLs.
Manage secure sessions with encrypted cookies for better security and persistence.
All link data, user details, and analytics are stored securely in MongoDB.
List of available endpoints for the URL Shortener Application.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/users | Fetch all users (requires token) |
| GET | /api/v1/users/:id | Fetch a specific user by ID (requires token) |
| POST | /api/v1/users/login | Login user |
| POST | /api/v1/users/logout | Logout user (requires token) |
| POST | /api/v1/users/register | Register a new user |
| PUT | /api/v1/users/:id | Update user info (requires token) |
| DELETE | /api/v1/users/:id | Delete a user (requires token) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/urls | Fetch all URLs for the logged-in user (requires token) |
| GET | /api/v1/urls/:id | Fetch short URL by ID (requires token) |
| POST | /api/v1/urls | Generate a new short URL (requires token) |
| PUT | /api/v1/urls/:id | Update an existing short URL (requires token) |
| DELETE | /api/v1/urls/:id | Delete a short URL (requires token) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/analytics | Fetch global analytics (requires token) |
| GET | /api/v1/analytics/:id | Fetch analytics for a specific URL (requires token) |
git clone
https://github.com/zdev2/shortlink.git
cd shortlinkgo mod tidy.env file with the necessary environment
variables.
go run main.gohttp://localhost:3000The URL Shortener application provides all the tools necessary to shorten, manage, and analyze URLs effectively. It is fast, secure, and scalable, making it ideal for modern web applications.