Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s4tyendra/url-shortner
Simple, Fast, Clean URL Shorter by DEVH.
https://github.com/s4tyendra/url-shortner
linkshortener url-shortener
Last synced: 2 days ago
JSON representation
Simple, Fast, Clean URL Shorter by DEVH.
- Host: GitHub
- URL: https://github.com/s4tyendra/url-shortner
- Owner: S4tyendra
- License: unlicense
- Created: 2023-10-28T17:25:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-06T07:05:22.000Z (8 months ago)
- Last Synced: 2024-05-07T07:51:11.846Z (8 months ago)
- Topics: linkshortener, url-shortener
- Language: TypeScript
- Homepage: https://s.devh.in
- Size: 176 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Shortener
A simple URL shortener service built with Next.js and MongoDB.
## Features
- Shorten long URLs.
- Redirect to the original URL using short slugs.
- Custom error handling for missing or invalid short URLs.
- Easy to self-host with MongoDB as the database.## Installation and Setup
### Prerequisites
- Node.js (v14 or later)
- MongoDB
- Git (optional, for cloning the repository)### Clone the Repository
You can clone this repository using Git:
```bash
git clone https://github.com/your-username/url-shortener.git
cd url-shortener
```### Installation
1. Install project dependencies:
```bash
npm install
```2. Create a `.env` file in the project's root directory with your MongoDB URI. You can get a MongoDB URI by following the [official MongoDB documentation](https://docs.mongodb.com/guides/cloud/connectionstring/).
```dotenv
MONGODB_URI="your-mongodb-uri-here"
```### Start the Application
Run the following command to start the development server:
```bash
npm run dev
```The URL shortener will be available at `http://localhost:3000`.
## Usage
1. Access the URL shortener web application.
2. Enter the original URL you want to shorten and click the "Shorten" button.
3. You'll receive a shortened URL that you can use to access the original URL.
4. If you try to access a shortened URL that doesn't exist or is invalid, you'll be redirected to a custom error page.## Self-Hosting Guide
To self-host this URL shortener on your server, follow these steps:
1. Clone the repository and install the required dependencies as mentioned in the installation section.
2. Create a `.env` file in the project's root directory and add your MongoDB URI. You can obtain a MongoDB URI by following the [official MongoDB documentation](https://docs.mongodb.com/guides/cloud/connectionstring/).
```dotenv
MONGODB_URI="your-mongodb-uri-here"
```3. Start the application using `npm run dev` and ensure that it's accessible on your server.
4. Make the application accessible to the public by setting up a domain and configuring your server to handle incoming requests.
5. Optionally, you can configure SSL for secure access using a tool like Let's Encrypt.
6. Test the application thoroughly to ensure it's working as expected.
7. Monitor and maintain your URL shortener to keep it available and responsive.
## License
This project is released into the public domain under the Unlicense. No restrictions apply. See the [UNLICENSE](LICENSE) file for details.
# Thankyou!