Skip to content

saikrishna1355/url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener

A simple URL shortener service built with Node.js, Express, MongoDB, and Mongoose.

Features

  • Generate short URLs from long URLs
  • Redirect short URLs to the original URLs
  • Store URLs in MongoDB
  • Simple server-side rendering with EJS (optional)

Prerequisites

  • Node.js (v14 or later recommended)
  • MongoDB running locally or remotely

Setup

  1. Clone the repository:

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

  2. Install dependencies:

    npm install

  3. Start the server:

    npm start

API Endpoints

POST /shorten

Create a short URL.

Request body:

{
    "originalUrl": "https://example.com/long-url"
}

Response:

{
    "originalUrl": "https://example.com/long-url",
    "shortUrl": "http://localhost:3000/shortCode"
}

GET /:shortCode

Redirects to the original URL.

About

A simple URL shortener service built with Node.js, Express, MongoDB, and Mongoose.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors