Git Product home page Git Product logo

url-shortner's Introduction

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:

git clone https://github.com/your-username/url-shortener.git
cd url-shortener

Installation

  1. Install project dependencies:
npm install
  1. 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.
MONGODB_URI="your-mongodb-uri-here"

Start the Application

Run the following command to start the development server:

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.

MONGODB_URI="your-mongodb-uri-here"
  1. Start the application using npm run dev and ensure that it's accessible on your server.

  2. Make the application accessible to the public by setting up a domain and configuring your server to handle incoming requests.

  3. Optionally, you can configure SSL for secure access using a tool like Let's Encrypt.

  4. Test the application thoroughly to ensure it's working as expected.

  5. 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 file for details.

Thankyou!

url-shortner's People

Contributors

s4tyendra avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.