A simple URL shortener application built with Node.js, Express, and MongoDB.
-
Clone the repository:
git clone https://github.com/yourusername/url-shortener.git cd url-shortener
-
Install the dependencies:
npm install
-
Start the MongoDB server (make sure MongoDB is installed and running on your machine):
mongod
-
Start the application:
npm start
Once the server is running, you can use the API to shorten URLs.
To shorten a URL, send a POST request to http://localhost:8001/url
with a JSON body containing the URL to be shortened:
{
"url": "https://www.example.com"
}
url-shortener/
├── .gitignore
├── connect.js
├── controllers/
│ └── url.js
├── index.js
├── models/
│ └── url.js
├── package.json
├── readme.md
└── routes/
└── url.js