This project implements a URL Shortener API that allows users to give their long URL and receive a shorter URL. Each shortened URL can be accessed, and the API tracks how many times each short link is clicked.
- Node.js: JavaScript runtime for server-side programming.
- Express.js: Web application framework for Node.js.
- MongoDB: NoSQL database for storing URLs.
- nanoid: A tiny, secure, URL-friendly unique ID generator.
- Shorten long URLs using unique IDs generated by
nanoid
. - Redirect original URLs from short URLs.
- Track the number of clicks on each short link.
- Store URLs in a MongoDB database.
{
"url": "https://www.example.com/some/long/url"
}
### Response
{
"shorturl": "http://localhost:8000/abc123",
"clicksHistory": [],
"totalclicks": 0
}