Skip to content

πŸ”— URL Shortener API A fast and secure URL shortener built with Node.js, Express, Drizzle ORM, and PostgreSQL. Features JWT authentication, Zod validation, and a clean, scalable architecture for modern backend development.

Notifications You must be signed in to change notification settings

raaj2493/URL-Shortner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— URL Shortener API

A full-featured URL shortener service built with Node.js, Express, and PostgreSQL.
This project provides RESTful APIs for user authentication, URL shortening, and analytics.


πŸš€ Features

  • πŸ” User Authentication β€” JWT-based signup and login
  • βœ‚οΈ URL Shortening β€” Convert long URLs to short codes
  • 🧩 URL Management β€” View and delete your shortened URLs
  • πŸ” Redirection β€” Automatic redirect to original URLs
  • πŸ›‘οΈ Secure & Type-safe β€” Built using Zod validation and Drizzle ORM

πŸ›  Tech Stack

| Category         | Technology           | Purpose                                  |
|------------------|----------------------|------------------------------------------|
| Backend          | Node.js + Express    | REST API development                     |
| Database         | PostgreSQL           | Relational data store                    |
| ORM              | Drizzle ORM          | Type-safe database queries & schema      |
| Containerization | Docker + Compose     | Local PostgreSQL instance                |
| Authentication   | JWT                  | Secure private routes                    |
| Validation       | Zod                  | Input validation                         |
| Testing          | Postman              | Manual API testing                       |

---

## πŸ“‹ Prerequisites  

Before you begin, make sure you have the following installed on your system:

- [Node.js](https://nodejs.org/) (v18 or above recommended)  
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)  
- [Postman](https://www.postman.com/) (for API testing)  
- [VS Code](https://code.visualstudio.com/) (recommended editor)

---

## πŸ—οΈ Project Structure  

```text
src/
β”œβ”€β”€ controllers/     # Route controllers
β”œβ”€β”€ services/        # Business logic
β”œβ”€β”€ models/          # Database models
β”œβ”€β”€ middleware/      # Custom middleware
β”œβ”€β”€ utils/           # Utility functions
β”œβ”€β”€ validation/      # Zod schemas
└── config/          # Configuration files


## πŸ”Œ API Endpoints

### πŸ§β€β™‚οΈ Auth Routes
```bash
| Method | Endpoint     | Description              | Auth Required |
|--------|--------------|--------------------------|----------------|
| POST   | '/signup'    | Register a new user      | ❌             |
| POST   | '/login'     | Login and receive token  | ❌             |


## πŸ”— URL Routes

| Method | Endpoint       | Description                                 | Auth Required |
|--------|----------------|---------------------------------------------|----------------|
| POST   | '/shorten'     | Create a short URL from a long one          | βœ…             |
| GET    | '/:shortCode'  | Redirect to the original URL                | ❌             |
| GET    | '/urls'        | Get all URLs created by the logged-in user  | βœ…             |
| DELETE | '/urls/:id'    | Delete a short URL (if it belongs to user)  | βœ…             |

About

πŸ”— URL Shortener API A fast and secure URL shortener built with Node.js, Express, Drizzle ORM, and PostgreSQL. Features JWT authentication, Zod validation, and a clean, scalable architecture for modern backend development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published