URI Shortener Service is a RESTful API built using Node.js, Express.js, MongoDB Atlas, and Mongoose. The application allows users to generate shortened URLs, redirect to the original URLs, and track URL usage statistics.
- Shorten long URLs into unique short codes
- Redirect users to the original URL
- Track the number of clicks for each shortened URL
- Store URL data in MongoDB Atlas
- RESTful API architecture
- Unique short code generation using NanoID
- Node.js
- Express.js
- MongoDB Atlas
- Mongoose
- NanoID
- Dotenv
URI-Shortener-Service/
│
├── src/
│ ├── controllers/
│ │ └── urlController.js
│ │
│ ├── models/
│ │ └── Url.js
│ │
│ ├── routes/
│ │ └── urlRoutes.js
│ │
│ └── server.js
│
├── .env
├── package.json
├── package-lock.json
└── README.md
- Clone the repository
git clone <repository-url>- Navigate to the project folder
cd URI-Shortener-Service- Install dependencies
npm install- Configure environment variables
Create a .env file and add:
MONGO_URI=your_mongodb_connection_string
PORT=5000- Start the server
npm run devPOST
/shortenRequest Body:
{
"originalUrl": "https://google.com"
}Response:
{
"message": "Short URL created",
"shortCode": "VvmXTT"
}GET
/:shortCodeExample:
/VvmXTTRedirects to the original URL.
GET
/stats/:shortCodeExample:
/ stats/VvmXTTResponse:
{
"originalUrl": "https://google.com",
"shortCode": "VvmXTT",
"clicks": 1
}| Field | Type | Description |
|---|---|---|
| originalUrl | String | Original long URL |
| shortCode | String | Generated unique code |
| clicks | Number | Number of redirects |
- Custom short URLs
- URL expiration
- User authentication
- QR code generation
- Advanced analytics dashboard
Advaita Praveen Kumar Parikkal
This project is developed for internship and learning purposes.