Skip to content

manuelam2003/shortify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

For a URL shortener service like Shortify, you would need several essential routes to handle shortening, redirecting, and managing URLs, along with user authentication and support for analytics. Below are the key routes you should consider for Shortify:

1. Public Routes

These routes are accessible without user authentication.

1.1. Home Route (Shortening Route)

  • Route: GET /

  • Purpose: Displays the homepage where users can paste a long URL to shorten it.

  • Response: HTML page with a form to submit the URL.

  • Route: POST /shorten

  • Purpose: Accepts a long URL and returns a shortened URL.

  • Request Payload (JSON or Form Data):

    {
      "url": "https://www.example.com"
    }
  • Response:

    {
      "shortened_url": "http://shortify.io/abc123"
    }
  • Response for Custom URL:

    {
      "shortened_url": "http://shortify.io/customname"
    }

1.2. URL Redirect Route

  • Route: GET /:shortCode
  • Purpose: Redirects the user to the original long URL based on the short code.
  • Example: GET /abc123
    • Redirects to the long URL associated with the short code abc123 (e.g., https://www.example.com).
  • Response: HTTP 301/302 redirect to the original URL.

2. Analytics & URL Management Routes (Optional for Public or Authenticated Users)

2.1. Analytics Route

  • Route: GET /:shortCode/stats
  • Purpose: Returns statistics (e.g., number of clicks, referrers, countries, devices) for a particular shortened URL.
  • Example: GET /abc123/stats
  • Response:
    {
      "clicks": 150,
      "referrers": ["google.com", "facebook.com"],
      "countries": ["USA", "Canada"],
      "devices": ["desktop", "mobile"]
    }

3. Authenticated User Routes

These routes require the user to be logged in to access their shortened URL history, analytics, or manage custom URLs.

3.1. User Dashboard Route

  • Route: GET /dashboard
  • Purpose: Displays a dashboard where authenticated users can manage all of their shortened URLs.
  • Response: List of all URLs the user has shortened, along with options to edit or delete them.

3.2. Manage Shortened URL Routes

  • Route: POST /url/edit/:shortCode

  • Purpose: Allows the user to edit the original URL or the short code.

  • Request Payload:

    {
      "new_url": "https://newurl.com",
      "new_short_code": "newshortcode"
    }
  • Response: Success or error message.

  • Route: DELETE /url/delete/:shortCode

  • Purpose: Deletes a shortened URL created by the user.

  • Response: Success or error message.

4. User Authentication Routes

These routes handle user registration, login, and account management.

4.1. Sign Up Route

  • Route: GET /signup

  • Purpose: Displays the signup page where users can create an account.

  • Response: HTML form to sign up.

  • Route: POST /signup

  • Purpose: Handles user registration by accepting username, email, and password.

  • Request Payload:

    {
      "username": "newuser",
      "email": "newuser@example.com",
      "password": "password123"
    }
  • Response: Success or error message.

4.2. Login Route

  • Route: GET /login

  • Purpose: Displays the login page.

  • Response: HTML form to log in.

  • Route: POST /login

  • Purpose: Authenticates the user using email and password.

  • Request Payload:

    {
      "email": "user@example.com",
      "password": "password123"
    }
  • Response: Success message with session or token information.

4.3. Logout Route

  • Route: POST /logout
  • Purpose: Logs the user out by invalidating the session or token.
  • Response: Success message.

5. Other Optional Routes

5.1. Pricing Route

  • Route: GET /pricing
  • Purpose: Displays a page with pricing information for premium users.
  • Response: HTML page with pricing details.

5.2. API Routes (For Developers)

  • Route: POST /api/shorten

  • Purpose: Allows developers to shorten URLs programmatically using an API key.

  • Request Payload (JSON):

    {
      "url": "https://www.example.com",
      "api_key": "user-api-key"
    }
  • Response:

    {
      "shortened_url": "http://shortify.io/xyz789"
    }
  • Route: GET /api/:shortCode/stats

  • Purpose: Provides programmatic access to URL analytics for developers.

  • Response (JSON):

    {
      "clicks": 200,
      "referrers": ["twitter.com", "linkedin.com"]
    }

5.3. Help and Support Route

  • Route: GET /support
  • Purpose: Displays a support page with FAQs and contact details.
  • Response: HTML page with support information.

5.4. Terms of Service & Privacy Policy

  • Route: GET /terms

  • Purpose: Displays the Terms of Service for the website.

  • Response: HTML page with legal information.

  • Route: GET /privacy

  • Purpose: Displays the Privacy Policy for the website.

  • Response: HTML page with details on data collection and usage.


Summary of Core Routes for Shortify:

Route Method Description
/ GET Displays homepage to shorten URLs.
/shorten POST Shortens a URL and returns the shortened URL.
/:shortCode GET Redirects to the original URL based on short code.
/:shortCode/stats GET Displays analytics for a shortened URL.
/dashboard GET Shows user's URL management dashboard.
/url/edit/:shortCode POST Allows the user to edit a shortened URL.
/url/delete/:shortCode DELETE Deletes a shortened URL.
/signup GET Displays signup page.
/signup POST Registers a new user.
/login GET Displays login page.
/login POST Logs the user in.
/logout POST Logs the user out.

This structure covers all the key features, from basic shortening to user management, API access, and analytics. You can add more routes depending on advanced features like paid plans or custom domains.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors