8000 GitHub - avent18/LinkShortener: Shortens a long url into a tinyUrl
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

avent18/LinkShortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

URL Shortener

A simple URL shortener built with Node.js, Express, PostgreSQL, and React.

Features

  • Shorten long URLs into unique short links.
  • Store and retrieve URLs using PostgreSQL.
  • Redirect short URLs to their original long URLs.
  • Simple frontend to create and display shortened links.

Tech Stack

  • Backend: Node.js, Express.js, PostgreSQL
  • Frontend: React.js
  • Database: PostgreSQL

Setup Guide

Prerequisites

  • Node.js installed
  • PostgreSQL installed and running

Database Setup

  1. Create a PostgreSQL database:
    CREATE DATABASE urlShortener;
  2. Update database credentials in index.js (backend file):
    const db = new db.Client({
      user: "your_username",
      host: "localhost",
      database: "urlShortener",
      password: "your_password",
      port: 5432,
    });
  3. The table will be automatically created when the server starts.

Backend Setup

  1. Install dependencies:
    npm install express pg shortid cors
  2. Start the server:
    node index.js

Frontend Setup

  1. Install dependencies:
    npm install axios
  2. Add LinkShortener component in your React app.

API Endpoints

1. Shorten URL

  • Endpoint: POST /shorten
  • Request Body:
    {
      "longUrl": "https://example.com"
    }
  • Response:
    {
      "shortUrl": "abc123"
    }

2. Redirect to Original URL

  • Endpoint: GET /:shortUrl
  • Example: GET /abc123 → Redirects to https://example.com

Running the Application

  1. Start PostgreSQL and ensure the database is running.
  2. Start the backend server.
  3. Run the frontend React app.
  4. Open the frontend in a browser and test URL shortening.

License

This project is open-source and available under the MIT License.


Developed by Naveen Kumar 🚀

About

Shortens a long url into a tinyUrl

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0