Lightning Link
Scalable URL Shortener written in TypeScript / Express with React frontend. Live Version @ https://ltng.link/
The goal of Lightning Link is to design a highly scalable URL shortener that does not have collisions when generating a new url and minimal number of database queries.
The API sit behind a Load Balancer, as many API services can be launched as needed.
Load balancing occurs in a round robin format (mostly for proof of concept), and rate limiting is shared across all API instances using Redis for storing Rate Limiting data.
Analytic data is provided to the Creator of the short URL showing the Geo locations of visitors and total number of visits.
Implemented Features
- Basic Scalable URL Shortener Backend
- Backend Analytics (See visits, geographic data etc..)
- Frontend for URL Shortener
- Frontend Auth + Analytics (Working on it..)
Planned Features
- Optimization + Design Tweaks
API Documentation
Shorten URL
Returns an Short URL for Given Destination URL.
If userId given allows you to pull analytic data and links shortened route to your userId
-
URL
/shorten
-
Method:
POST
-
URL Params
Required:
destination=[string]
Optional:
forceNewUrl=[boolean]
userId=[string]
-
Success Response:
- Code: 200
Content:slug : 0daajd
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:Must provide a long url
- Code: 400 BAD REQUEST
-
Sample Call:
axios.post('/shorten?destination=www.google.com') .then((res) => { console.log(res) -> "0004c92" }
Get Redicretion URL
Returns the original URL for you to redirect the user to
-
URL
/:slug
-
Method:
GET
-
URL Params
Required:
slug=[string]
-
Success Response:
- Code: 200
Content:destination : www.google.com
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:Must provide a long url
- Code: 400 BAD REQUEST
-
Sample Call:
axios.get('/0004c92') .then((res) => { console.log(res) -> "http://www.google.com" }
Get Analytic Data
Returns the Analytic Data of a Short URL given your UserID is the creator
-
URL
/analytic/:slug
-
Method:
GET
-
URL Params
Required:
slug=[string]
userId=[string]
-
Success Response:
- Code: 200
Content:{ "urls_slug": "000BLjl", "creator_user_id": "some_user_id", "visits": 3, "worlds": "[{\"city\": \"Montreal\", \"visits\": \"2\", \"country\": \"Canada\", \"continent\": \"NA\"}]" }
- Code: 200
-
Error Response:
- Code: 401 UNAUTHORIZED
Content:Unauthorized Route
- Code: 401 UNAUTHORIZED
-
Sample Call:
axios.get('/analytics/0004c92') .then((res) => { console.log(res) }
License
Copyright Eric Ellbogen 2019
- This project is under the GNU V3 license. Find it here.