/URL-Shortener

URL Shortener Built on the MERN stack

Primary LanguageJavaScript

URL Shortener

You can try this Here

NOTE: This is hosted on free tier on render. This might cause a delay in the response of the first request after a period of inactivity while the instance spins up.

Home Page

drawing

URLs and Summarization

drawing

drawing

Shorten URLs

POST /url /shorten
Parameters
name type data type description
url required string The URL to be shortened
Headers
name type data type description
Authorization optional Bearer Bearer token returned by the login API. If authenticated, the URLs will be logged against the user and can be retrieved later
Response Body
 {
    "success": true,
    "short_url": "http://localhost:5000/EshTLkMTxHT482mr"
 }
Example cURL
 curl -L 'http://localhost:5000/url/shorten' -H 'Content-Type: application/json' -d '{ "url": "https://google.com"}'

Login an existing user or Create a new one

POST /user/login
Request Body
name type data type description
google_oauth_sub required string Unique identifier returned from Google Oauth
Response Body
 {
    "token": "JWT",
    "new_user": false
 }
Example cURL
 curl -L 'http://localhost:5000/user/login' -H 'Content-Type: application/json' -d '{ "google_oauth_sub": "1234567890", }'

List the URLs generated by a user

POST /user/my_urls
Request Body

None

Headers
name type data type description
Authorization required Bearer Bearer token returned by the login API
Response Body
 [
    {
        "base_url": "google.com",
        "url": "http://google.com",
        "short_url": "http://127.0.0.1:5000/EseKyBGvpFcwZlTQ",
        "createdAt": "2023-06-09T06:25:08.202Z"
    },
    {
        "base_url": "bing.com",
        "url": "http://bing.com",
        "short_url": "http://127.0.0.1:5000/EsfizntxJ1G2rt4f",
        "createdAt": "2023-06-09T07:58:06.851Z"
    },
 ]
Example cURL
 curl -L -X POST 'http://localhost:5000/user/my_urls' -H 'Authorization: Bearer <Bearer Token>' -d ''

Summarise the URLs (by count of clicks) generated by a user

POST /user/summarise /{summarize-by-column}
Request Body

None

Headers
name type data type description
Authorization required Bearer Bearer token returned by the login API
Response Body
 [
    {
        "base_url": "google.com",
        "count": 4
    }, {
        "base_url": "bing.com",
        "count": 4
    }, {
        "base_url": "chat.openai.com",
        "count": 4
    }
 ]
Example cURL
 curl -L -X POST 'http://localhost:5000/user/my_urls' -H 'Authorization: Bearer <Bearer Token>' -d ''