Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fitsumhelina/codealpha_url_shortener
A URL shortener service that allows users to shorten long URLs and redirects users to the original URL when accessed. This project uses Express.js (Node.js) to handle URL redirection and MongoDB to store mappings.
https://github.com/fitsumhelina/codealpha_url_shortener
backend expressjs mern-stack nodejs project url-shortener
Last synced: about 4 hours ago
JSON representation
A URL shortener service that allows users to shorten long URLs and redirects users to the original URL when accessed. This project uses Express.js (Node.js) to handle URL redirection and MongoDB to store mappings.
- Host: GitHub
- URL: https://github.com/fitsumhelina/codealpha_url_shortener
- Owner: Fitsumhelina
- License: other
- Created: 2024-07-20T08:07:23.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T21:47:57.000Z (3 months ago)
- Last Synced: 2024-08-20T23:31:51.819Z (3 months ago)
- Topics: backend, expressjs, mern-stack, nodejs, project, url-shortener
- Language: JavaScript
- Homepage: https://url-azure.vercel.app/
- Size: 1.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
---
# URL Shortener Service
A URL shortener service that allows users to shorten long URLs and redirects users to the original URL when accessed. This project uses Express.js (Node.js) to handle URL redirection and MongoDB to store mappings.
![Portfolio Screenshot](./public//assets//site.png)
## Features
- Shorten long URLs.
- Redirect to the original URL using the shortened link.
- Simple frontend for inputting URLs and getting shortened links.
- Copy button to easily copy the shortened link.## Tech Stack
- **Backend:** Node.js, Express.js
- **Database:** MongoDB
- **Frontend:** HTML, CSS, JavaScript## Project Structure
```plaintext
url-shortener/
├── .env
├── .gitignore
├── package.json
├── README.md
├── server.js
├── models/
│ └── Url.js
├── routes/
│ └── url.js
├── controllers/
│ └── urlController.js
├── config/
│ └── db.js
└── public/
├── index.html
├── css/
│ └── styles.css
└── js/
└── scripts.js
```## Installation
### Clone the repository
```bash
git clone https://github.com/fitsumhelina/url-shortener.git
cd url-shortener
```### Install dependencies
```bash
npm install
```### Create a `.env` file and add the following variables:
```env
PORT=5000
MONGO_URI=your_mongodb_connection_string
BASE_URL=http://localhost:5000
```### Run the server
```bash
npm run dev
```### Access the application
Open your browser and go to [http://localhost:5000](http://localhost:5000).
## Usage
- **Shorten a URL:** Enter a long URL in the input field and click the "Shorten" button.
- **Copy the Shortened URL:** Click the "Copy" button to copy the shortened URL to the clipboard.
- **Redirect to the Original URL:** Click the shortened URL to be redirected to the original long URL.## API Endpoints
### Shorten URL
- **URL:** `/shorten`
- **Method:** `POST`
- **Body:** `{"longUrl": "http://example.com"}`
- **Response:**
```json
{
"longUrl": "http://example.com",
"shortUrl": "http://localhost:5000/abc123",
"urlCode": "abc123",
"date": "2023-07-20T14:00:00.000Z"
}
```### Redirect to Original URL
- **URL:** `/:code`
- **Method:** `GET`
- **Response:** Redirects to the original long URL.## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## live
- check it here : https://url-azure.vercel.app/
- disclaimer!! : currently it is not working on deployed version.## Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
## Contact
- **Name:** Fitsum Helina
- **Email:** [click here]([email protected])
- **Portfolio:** [fitsumhelina.com](https://fitsumhelina.vercel.app)---