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.
- 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.).
Ensure you have the following software installed on your machine:
- Node.js (v16.x or higher)
- MongoDB
- Clone this repository to your local machine.
git clone https://github.com/your-username/shortify.git
cd shortify
- Install the project dependencies.
npm install
using yarn
yarn install
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
.
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).
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.
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'
We welcome contributions to improve Shortify. If you find a bug or want to add a new feature, please follow the steps below:
- Fork the repository and create a new branch from the
main
branch. - Make your changes and test thoroughly.
- Commit your changes with descriptive commit messages.
- Push your branch to your forked repository.
- 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.
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!