This is a simple URL shortener web application built with Node.js, Express, and MongoDB. It allows users to shorten long URLs into more manageable shortened versions. It also tracks the Click on the URL
- Shorten long URLs into unique, shorter versions.
- Redirect users to the original long URL when they access the shortened URL.
- MongoDB integration to store URL mappings.
- MVC (Model-View-Controller) architecture for better organization and scalability.
- Soon to be upgraded with server-side rendering (SSR) using EJS.
- Node.js
- npm (Node Package Manager)
- MongoDB (Make sure you have MongoDB installed and running on your system)
-
Clone this repository:
-
Install dependencies:
npm install
-
Configure MongoDB:
- Make sure MongoDB is running on your system.
- Update the MongoDB connection URI in `connection.js
-
Start the server:
npm start
-
Open your web browser and go to
http://localhost:3000
to access the URL shortener application.
- URL:
/url
- Method:
POST
- Request Body:
url
: The long URL to be shortened
- Success Response:
- Code: 200
- Content:
{ "message": "URL created successfully" }
- URL:
/url
- Method:
GET
- Success Response:
- Code: 200
- Content: An array of shortened URL objects
- URL:
/url/:shortId
- Method:
GET
- URL Parameters:
shortId
: The unique identifier of the shortened URL
- Success Response:
- Redirect: Redirects to the original long URL associated with the
shortId
- Redirect: Redirects to the original long URL associated with the