https://github.com/thedevelop3r/url-shortner
this project was a challenge at freecodecamp for url shortning | i used mongoose as database some extra packages and wrote its logic , passed the test
https://github.com/thedevelop3r/url-shortner
Last synced: 12 months ago
JSON representation
this project was a challenge at freecodecamp for url shortning | i used mongoose as database some extra packages and wrote its logic , passed the test
- Host: GitHub
- URL: https://github.com/thedevelop3r/url-shortner
- Owner: Thedevelop3r
- Created: 2022-08-19T13:50:49.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-19T18:27:49.000Z (almost 4 years ago)
- Last Synced: 2025-02-07T08:48:52.486Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# URL Shortener Microservice
This is the boilerplate code for the URL Shortener Microservice project. Instructions for building your project can be found at https://www.freecodecamp.org/learn/back-end-development-and-apis/back-end-development-and-apis-projects/url-shortener-microservice.
---
# URL Shortener
This project is a solution to a FreeCodeCamp challenge for building a URL shortener service. It uses Node.js, Express, and MongoDB (via Mongoose) to provide a simple web API for shortening URLs. The application includes additional logic and packages to meet challenge requirements and all tests have been passed.
## Features
- Shorten long URLs to concise short links
- Store and retrieve URLs using MongoDB with Mongoose
- RESTful API endpoints
- Fully passes FreeCodeCamp test suite
## Getting Started
### Prerequisites
- Node.js (v14 or later)
- npm
- MongoDB (local or Atlas)
### Installation
1. **Clone the repository:**
```bash
git clone https://github.com/Thedevelop3r/url-shortner.git
cd url-shortner
```
2. **Install dependencies:**
```bash
npm install
```
3. **Set up environment variables:**
Create a `.env` file in the root directory and add your MongoDB URI:
```
MONGO_URI=your_mongodb_connection_string
PORT=3000
```
4. **Start the application:**
```bash
npm start
```
The server will run on `http://localhost:3000` by default.
## API Endpoints
- **POST `/api/shorturl`**
- Request Body: `{ "url": "https://example.com" }`
- Response: `{ "original_url": "https://example.com", "short_url": 1 }`
- **GET `/api/shorturl/:short_url`**
- Redirects to the original URL corresponding to the provided short URL code.
## Technologies Used
- JavaScript (Node.js, Express)
- MongoDB & Mongoose
- CSS (for any frontend)
- Shell scripts (for automation tasks)
## License
This project is open-source and available under the [MIT License](LICENSE).