In today's fast-paced digital world, sharing lengthy URLs can be a hassle, especially when you're limited by character counts or simply want a cleaner, more shareable link. Enter Shawty, a lightweight yet powerful URL shortener that not only compacts long URLs into bite-sized links but also offers the added convenience of expiration support.
The Problem
Have you ever tried to share a lengthy URL, only to struggle with formatting or character limits? Or perhaps you've encountered situations where you'd like to share a temporary link that becomes obsolete after a certain period? Shawty was born to solve these very problems, providing a seamless solution for shortening URLs and ensuring they remain accessible only for a specified duration.
The Solution
Shawty takes a long URL like https://www.youtube.com/watch?v=NpUuuT_EzSs
and transforms it into a concise, shareable link such as https://biturl.top/zE3YBr
. But that's not all – with Shawty, you can also set an expiration date for your shortened URLs, ensuring that they remain active only for the desired period.
This project was inspired by the coding challenge Write Your Own URL Shortener and serves as a practical solution to the problem of managing long and temporary URL
How It Works
Shawty exposes a simple yet powerful API endpoint for shortening URLs:
[POST]/short request
{
"url":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects",
"expire":"2022-10-05T14:48:00.000Z"
}
response
{
"key": "79f292",
"long_url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects",
"short_url": "http://localhost:4000/short/79f292",
"expire": "2022-10-05T14:48:00.000Z"
}
When a shortened URL is accessed, Shawty performs a 302 HTTP redirect to the original long URL, ensuring a seamless user experience.
Technologies Used
Shawty is built using the following technologies:
- Node.js: A powerful JavaScript runtime for building server-side applications.
- MySQL: A reliable and scalable open-source relational database for storing URL mappings and expiration information.
- Docker: A containerization platform that simplifies deployment and ensures consistent execution environments.
Getting Started
To get started with Shawty, simply clone the repository from GitHub and follow the installation and usage instructions provided in the README.