Tech Stack:
-
Endpoint:
/api/tinify/shorten
-
HTTP Method:
POST
-
Payload:
{
"originalUrl": "https://www.example.com"
}
- Description: Accepts a lengthy URL and returns its shortened form. If the provided URL is either invalid or inaccessible, an error will be thrown. The function first verifies if the URL is already present in the database. If so, its existing shortened code will be returned; otherwise, a new code will be generated and stored alongside the original URL in the database.
- Endpoint:
/{shortCode}
- HTTP Method:
GET
- Parameter:
- shortCode: Represents the shortened version of an original URL.
- Description: Given a
shortCode
, the system fetches the associated original URL and redirects the user to that URL. If no match is found, a 404 Not Found response is triggered.