Forks Stars Releases Last Commit Website

DotLink - Simple URL Shortener

DotLink is a minimal URL shortener that allows the creation of shortened links with optional custom aliases. Anyone can access shortened links, and the API also provides statistics such as click counts and original URLs.

Live Demo

https://dotlink-url-shortener.vercel.app

Features

Setup

1. Clone the Repository

git clone https://github.com/Aarondoran/Node-URL-shortener.git
cd Node-URL-shortener

2. Install Dependencies

npm install

3. Configure Environment Variables

PORT=3030
DATABASE_URL=postgresql://YOUR_USERNAME:YOUR_PASSWORD@YOUR_HOST/YOUR_DATABASE

4. Set Up the Database

CREATE TABLE urls (
  id SERIAL PRIMARY KEY,
  short_id VARCHAR(255) NOT NULL,
  original_url TEXT NOT NULL,
  clicks INTEGER DEFAULT 0,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

5. Start the Server

node server.js

API Endpoints

Shorten a URL

POST /api/shorten

{
  "originalUrl": "https://example.com",
  "customAlias": "myalias"
}

Redirect to Original URL

GET /:short_id

Check Link Information

GET /check/:id