Skip to content

URL shortener project built using Node.js, express, and Mongoose.

License

Notifications You must be signed in to change notification settings

amjadbouhouch/shortify

Repository files navigation

Shortify - URL Shortener Project

Shortify is a URL shortener project built using Node.js, TypeScript, and Mongoose. It allows users to create short URLs from their original URLs, making it easier to share and remember links. The shortened URLs generated by Shortify are more concise and convenient to use.

Table of Contents

Features

  • Shorten long URLs to compact and shareable short links.
  • Customizable short link aliases for easy recall.
  • Redirect users from the short link to the original URL seamlessly.
  • View statistics and analytics for shortened URLs (e.g., number of clicks, referrers, etc.).

Getting Started

Prerequisites

Ensure you have the following software installed on your machine:

  • Node.js (v16.x or higher)
  • MongoDB

Installation

  1. Clone this repository to your local machine.
git clone https://github.com/your-username/shortify.git
cd shortify
  1. Install the project dependencies.
npm install

using yarn

yarn install

Configuration

Before running the application, make sure to set up the required environment variables. Create a .env file in the root of the project and configure the following variables:

# Required
MONGODB_URI=your_mongodb_uri
# Optional default TO: http://localhost:<PORT> 
BASE_URL=your_base_url

Replace your_mongodb_uri with the MongoDB connection URI, and you can also change the PORT if needed or BASE_URL.

Usage

To start the Shortify server, run the following command:

npm dev

The server will now be running at http://localhost:3000 (or the specified port in the .env file).

API Endpoints

The following API endpoints are available for interacting with the Shortify service:

  • POST /shorten: Create a short link by providing the original URL.
  • GET /:shortId: Redirect to the original URL based on the provided short id.
  • GET /stats/:shortCode: Retrieve statistics for a specific short link.

The API is designed to be RESTful, and all responses are returned in JSON format.

Docker

You can also run Shortify using Docker. Below is the Docker configuration:

docker compose build shortify
docker compose up -d
version: '2.4'
services:
  shortify:
    hostname: shortify
    env_file:
      - .env
    build:
      context: .
    ports:
      - '3000:3000'

Contributing

We welcome contributions to improve Shortify. If you find a bug or want to add a new feature, please follow the steps below:

  1. Fork the repository and create a new branch from the main branch.
  2. Make your changes and test thoroughly.
  3. Commit your changes with descriptive commit messages.
  4. Push your branch to your forked repository.
  5. Create a pull request against the main branch of the original repository.

We will review your pull request as soon as possible and provide feedback.

License

Shortify is open-source software licensed under the MIT License.


Thank you for using Shortify! If you have any questions or need assistance, please feel free to contact us or open an issue in the repository. Happy shortening!