Skip to content

The URL Shortener project is built using Node.js, Express, and MongoDB with Mongoose. Its primary functionality is to shorten lengthy URLs into concise ones. Additionally, the application incorporates a JWT (JSON Web Token) authentication strategy to authenticate users securely.

Notifications You must be signed in to change notification settings

codingXpert/URL-Shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener

This project is a URL shortener that allows users to shorten long URLs into shorter ones.

Getting Started

To get started with this project, follow these steps:

Prerequisites

  • Node.js installed on your machine
  • MongoDB installed or access to a MongoDB instance

Installation

  1. Clone the repository:

    git clone https://github.com/codingXpert/URL-Shortener
    
  2. Navigate to the project directory:

    cd url-shortener
    
  3. Install dependencies:

    npm install
    
  4. Set up environment variables: Create a .env file in the root directory and define the following variables:

    LOCAL_DATABASE=mongodb://localhost:27017/link_shortener
    PROD_DATABASE=mongodb+srv://<username>:<password>@<cluster>/<database>
    SALT_CONSTANT=10
    JWT_SECRET=your_jwt_secret
    EXPIRES_IN=1d
    NODE_ENV=development
    

Usage

  • To run the project in development mode:
    npm run start:dev
    
  • To run the project in production mode:
    npm run start:prod
    
    

Features

  • Short Url: AliasShorten long URLs into custom or randomly generated short URLs.

  • API Integration: Provide a RESTful API for users to programmatically interact with the URL shortening service.

  • JWT Authentication: Implemented JWT (JSON Web Token) authentication strategy for secure user login and session management.

  • MongoDB Atlas Integration: Employed MongoDB Atlas as the production database, ensuring scalability, reliability, and cloud-based data storage.

  • Security Middleware:

Helmet: Integrated Helmet to set various HTTP headers, enhancing security by protecting against common web vulnerabilities.

express-mongo-sanitize: Employed express-mongo-sanitize to sanitize user-supplied data against NoSQL Injection attacks.

xss-clean: Implemented xss-clean to sanitize user input from potential cross-site scripting (XSS) attacks, preventing script injections.

APIS(Accessible While Production)

  • Register User: https://url-shortener-rfpt.onrender.com/api/user/register
  • User Login: https://url-shortener-rfpt.onrender.com/api/user/login
  • Short Url: https://url-shortener-rfpt.onrender.com/api/url/shorten
  • Access Original Url: https://url-shortener-rfpt.onrender.com/api/url/9VelUQjTK

APIS(Accessible While Development)

  • Register User: http://localhost:8000/api/user/register
  • User Login: http://localhost:8000/api/user/login
  • Short Url: http://localhost:8000/api/url/shorten
  • Access Original Url: http://localhost:8000/api/url/9VelUQjTK

Postman Documentation

    https://documenter.getpostman.com/view/20576167/2s9Ykrbzvk

Deployed Link

  • Access all the available APIs using Swagger-UI
   https://url-shortener-rfpt.onrender.com/api-docs/

About

The URL Shortener project is built using Node.js, Express, and MongoDB with Mongoose. Its primary functionality is to shorten lengthy URLs into concise ones. Additionally, the application incorporates a JWT (JSON Web Token) authentication strategy to authenticate users securely.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published