- TINY-URL is a simple URL shortening service that allows users to convert long URLs into short, easily shareable links.
- This is inspired from the idea of actual tinyurl website.
- Backend: Node.js,Express.js
- Database: Postgres using supabase
- Frontend: React(vite),Bootstarp using
CDN - Testing is done with help of
postman
- Clone the repository:
git clone https://github.com/themysterysolver/TINY-URL.git cd TINY-URL - Install dependecy
npm install cd frontend npm install - Connect to
supabasewhich is aBaaS(backend as a service),create a table with below schema
create table public.urls (
id bigint generated by default as identity not null,
long_url character varying null,
short_url character varying null,
created_at timestamp with time zone not null default now(),
last_used timestamp with time zone null default now(),
constraint urls_pkey primary key (id)
) TABLESPACE pg_default;
- Create a
.envfile,fill the .env variables with help of supabase connection.
- Go to
Database > connect > click the connection type to **Node.js** > copy parameters - env variables should match
db.js
- Run the program
node index.js
cd frontend
npm run dev
nerd1910@DESKTOP-LOVHKH2:/mnt/d/Desktop/TINY-URL$ tree
.
├── db.js
├── frontend
│ ├── README.md
│ ├── eslint.config.js
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── public
│ │ └── vite.svg
│ ├── src
│ │ ├── App.css
│ │ ├── App.jsx
│ │ ├── assets
│ │ │ └── react.svg
│ │ ├── index.css
│ │ └── main.jsx
│ └── vite.config.js
├── index.js
├── package-lock.json
└── package.json
index.js- Has the complete backend api logicdb.js- helps to make connection/frontend/src/App.jsx- complete frontend logic with usestates
| Endpoint | Method | Description |
|---|---|---|
/shorten |
POST | Accepts a long URL and returns a unique short URL. |
/urls |
GET | Returns a list of all stored long and short URLs. |
/r/:short_url |
GET | Redirects the short URL to its corresponding long URL. |
NOTE: supabase connection is detailed in issues #4
Issue #1 talks about backend
Issue #2 talks about frontend
Issue #3 talks about exposed keys