Skip to content

NestURLShortener πŸ“πŸš€ A powerful and efficient URL shortening tool built with NestJS! Easily shorten long URLs and manage your links with this lightweight, scalable solution. Perfect for developers looking for a NestJS-based URL shortener. Optimize your links today! πŸ”—βœ¨

License

Notifications You must be signed in to change notification settings

riteshporiya/ShortenURLsWithNest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d79f065 Β· Jul 21, 2024

History

8 Commits
Jul 21, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 13, 2024
Jul 15, 2024
Jul 13, 2024
Jul 21, 2024
Jul 21, 2024
Jul 13, 2024
Jul 13, 2024
Jul 14, 2024

Repository files navigation

🌐 URL Shortener

A powerful URL shortener built with NestJS, PostgreSQL, and TypeORM! This project aims to provide a robust, user-friendly, and feature-rich URL shortening service.

πŸš€ Features

  • URL Validation: Ensure that only valid URLs are shortened. We use a library like class-validator for this purpose.
  • Custom Short URLs: Allow users to specify their own custom short URLs if desired.
  • Expiration Dates: Implement an expiration mechanism for short URLs, allowing users to set an expiry date.
  • Click Tracking: Track the number of clicks on each short URL.
  • Rate Limiting: Prevent abuse of the service with rate limiting.

πŸ› οΈ Built With

  • NestJS: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
  • PostgreSQL: A powerful, open-source object-relational database system.
  • TypeORM: An ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms, and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8).

πŸ“š Getting Started

Prerequisites

  • Node.js
  • PostgreSQL
  • TypeORM

Installation

  1. Clone the repository:
    git clone https://github.com/riteshporiya/ShortenURLsWithNest.git
    cd ShortenURLsWithNest
    
  2. Install dependencies:
npm install
  1. Configure the database:
# Create a .env file and set your PostgreSQL connection details
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=your_username
DB_PASSWORD=your_password
DB_NAME=your_database
DB_MIGRATION_TABLE_NAME=migrations
  1. Run database migrations:
npm run typeorm migration:run:local
  1. Start the server:
npm run start:dev

πŸ”§ Usage

URL Validation

Ensure only valid URLs are shortened using validator.

Custom Short URLs

Allow users to create custom short URLs by specifying a desired alias.

Expiration Dates

Set an expiry date for short URLs, after which they will no longer be accessible.

Click Tracking

Track the number of clicks for each short URL to monitor usage.

Rate Limiting

Prevent abuse by limiting the number of requests a user can make in a given time period.

πŸ—οΈ Architecture

  • Custom Decorator: Uses a custom decorator to set rate limit metadata on routes.
  • Interceptor: Implements an interceptor to handle rate limiting logic.
  • Dependency Injection: Uses NestJS's dependency injection system and module structure.
  • Reflector: Utilizes the Reflector to access metadata.
  • HttpException: Throws a standard HttpException for rate limit errors.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes or enhancements you would like to see.

Happy coding! πŸŽ‰

About

NestURLShortener πŸ“πŸš€ A powerful and efficient URL shortening tool built with NestJS! Easily shorten long URLs and manage your links with this lightweight, scalable solution. Perfect for developers looking for a NestJS-based URL shortener. Optimize your links today! πŸ”—βœ¨

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published