An URL shortener application built with Node.js, Express, and MongoDB. This project allows users to shorten long URLs and redirect to the original URL using the shortened version.
- Shorten long URLs
- Redirect to original URLs using the shortened URL
- Simple and clean user interface
- Environment-based configuration
- Backend: Node.js, Express.js
- Database: MongoDB (using Mongoose ODM)
- Environment Configuration: dotenv
Check out the live deployment of the URL Shortener: https://url-shortner-d80u.onrender.com
Before you begin, ensure you have met the following requirements:
- Node.js installed on your machine
- MongoDB server or MongoDB Atlas account
- Git installed on your machine
git clone https://github.com/yourusername/url-shortener.git
cd url-shortener
npm install
MongoUrl="mongodb+srv://username:[email protected]/yourdbname?retryWrites=true&w=majority"
PORT=3000
npm start
.
├── Controllers
│ └── url.js # URL shortener logic
├── Models
│ └── Url.js # Mongoose schema for storing URLs
├── Views
│ └── server.ejs # EJS template for the frontend
├── .env # Environment variables
├── .gitignore # Ignored files and directories
├── package.json # Node.js dependencies and scripts
├── server.js # Main application file
└── README.md # Project documentation
{
"longUrl": "https://www.example.com"
}
{
"shortUrl": "http://localhost:3000/abc123"
}