Skip to content

EeroLai/URLShortener

Repository files navigation

URLShortener

A lightweight self-hosted URL shortener built with Express and Firebase Realtime Database.

English | 繁體中文

URLShortener Overview

Introduction

URLShortener solves two practical needs in one service:

  • Create short links quickly on the home page
  • Manage links later in a dashboard (search, copy, delete, and view clicks)

Features

  • Create short URLs: POST /new, POST /new/
  • URL validation: only accepts http:// and https://
  • Unique short code generation with collision checks
  • Redirect by short code: GET /:shortURL
  • Click counting on each redirect
  • Dashboard page: GET /dashboard
  • Management APIs:
    • List URLs: GET /api/urls
    • Delete URL: DELETE /api/urls/:shortURL

Setup

  1. Copy env file:
cp .env.example .env
  1. Fill Firebase settings in .env
  2. Install dependencies:
npm install

Run

Development:

npm run dev

Production:

npm run start

Default URL: http://localhost:3000

Pages

  • Home: GET /
  • Dashboard: GET /dashboard

API Example

Create:

POST /new
{
  "originalURL": "https://example.com/article/123"
}
{
  "shortURL": "abc123xyz0"
}

List:

GET /api/urls

Delete:

DELETE /api/urls/:shortURL

Tech Stack

  • Node.js
  • Express
  • Firebase Realtime Database
  • Nano ID

About

A lightweight URL shortener with dashboard management, built with Express and Firebase Realtime Database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors